Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/taro_init/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Project {
init_git(&self.project_name, project_path_str.as_str())?;
let auto_install = self.auto_install.unwrap_or(true);
if auto_install {
install_deps(&self.npm, || self.call_success()).await?;
install_deps(&self.npm, project_path_str.as_str(), || self.call_success()).await?;
} else {
self.call_success();
}
Expand Down
6 changes: 5 additions & 1 deletion crates/taro_init/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
}
}

pub async fn install_deps<F>(npm: &NpmType, cb: F) -> anyhow::Result<()>
pub async fn install_deps<F>(npm: &NpmType, project_path: &str, cb: F) -> anyhow::Result<()>
where
F: FnOnce(),
{
Expand All @@ -139,6 +139,10 @@ where
"执行安装项目依赖 {}, 需要一会儿...",
style(command.to_owned() + " install").cyan().bold()
);

// 确保在项目目录中执行
env::set_current_dir(project_path)?;

let output = execute_command(command, &["install"]).await;
match output {
result::Result::Ok(_) => {
Expand Down