Skip to content

Commit

Permalink
Global install
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Browning committed Sep 22, 2023
1 parent a167bbf commit fb93cd5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/src/install/ceramic_app_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn install_ceramic_app_template(

tokio::fs::rename(&unzip_dir, &output_dir).await?;

npm_install(&output_dir, &None).await?;
npm_install(&output_dir, &None, false).await?;

let readme = output_dir.join("README.md");
let mut f = tokio::fs::OpenOptions::new()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/install/ceramic_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub async fn install_ceramic_daemon(
if let Some(v) = version.as_ref() {
program.push_str(&format!("@{}", v.to_string()));
}
npm_install_package(&working_directory, &program).await?;
npm_install_package(&working_directory, &program, true).await?;

let ans = match start_ceramic {
Some(true) => true,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/install/compose_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub async fn install_compose_db(
if let Some(v) = version.as_ref() {
program.push_str(&format!("@{}", v.to_string()));
}
npm_install_package(working_directory, &program).await?;
npm_install_package(working_directory, &program, true).await?;

let env_file = working_directory.join("composedb.env");
let mut f = tokio::fs::OpenOptions::new()
Expand Down
7 changes: 6 additions & 1 deletion cli/src/install/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use tokio::process::Command;
pub async fn npm_install_package(
working_directory: impl AsRef<Path>,
package: &str,
globally: bool,
) -> anyhow::Result<()> {
let status = Command::new("npm")
.args(&["init", "--yes"])
Expand All @@ -16,17 +17,21 @@ pub async fn npm_install_package(
anyhow::bail!("Failed to init npm, cannot download {}", package);
}

npm_install(working_directory, &Some(&package)).await?;
npm_install(working_directory, &Some(&package), globally).await?;

Ok(())
}

pub async fn npm_install(
working_directory: impl AsRef<Path>,
package: &Option<&str>,
globally: bool,
) -> anyhow::Result<()> {
let msg = "Installing dependencies";
let mut args = vec!["install"];
if globally {
args.push("-g");
}
let msg = if let Some(p) = package {
args.push(p);
format!("{} for {}", msg, p)
Expand Down

0 comments on commit fb93cd5

Please sign in to comment.