Skip to content

Commit

Permalink
fix: npm install instead of npm ci (apollographql#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Mar 15, 2022
1 parent e30bb72 commit 9e049cb
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 45 deletions.
41 changes: 30 additions & 11 deletions build_harmonizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,40 @@ fn main() {
create_snapshot().expect("unable to create v8 snapshot: query_runtime.snap");
}

// runs `npm ci` && `npm run build` in the current `harmonizer-x` workspace crate
// runs `npm install` && `npm run build` in the current `harmonizer-x` workspace crate
fn bundle_for_deno() {
let npm = which::which("npm").expect("You must have npm installed to build this crate.");
let current_dir = std::env::current_dir().unwrap();

println!(
"cargo:warning=running `npm ci` in {}",
&current_dir.display()
);
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["ci"])
.status()
.expect("Could not get status of `npm ci`")
.success());
if cfg!(debug_assertions) {
// in debug mode we want to update the package-lock.json
// so we run `npm install`
println!(
"cargo:warning=running `npm install` in {}",
&current_dir.display()
);
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["install"])
.status()
.expect("Could not get status of `npm install`")
.success());
} else {
// in release mode, we're probably running in CI
// and want the version we publish to match
// the git source
// so we run `npm ci`.
println!(
"cargo:warning=running `npm ci` in {}",
&current_dir.display()
);
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["ci"])
.status()
.expect("Could not get status of `npm ci`")
.success());
}

println!(
"cargo:warning=running `npm run format` in {}",
Expand Down
54 changes: 27 additions & 27 deletions harmonizer-2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 23 additions & 7 deletions router-bridge/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ fn update_bridge() {
let npm = which::which("npm").unwrap();
let current_dir = std::env::current_dir().unwrap();

println!("cargo:warning=running `npm ci`");
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["ci"])
.status()
.unwrap()
.success());
if cfg!(debug_assertions) {
// in debug mode we want to update the package-lock.json
// so we run `npm install`
println!("cargo:warning=running `npm install`");
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["install"])
.status()
.unwrap()
.success());
} else {
// in release mode, we're probably running in CI
// and want the version we publish to match
// the git source
// so we run `npm ci`.
println!("cargo:warning=running `npm ci`");
assert!(Command::new(&npm)
.current_dir(&current_dir)
.args(&["ci"])
.status()
.unwrap()
.success());
}

println!("cargo:warning=running `npm run fmt`");
assert!(Command::new(&npm)
Expand Down

0 comments on commit 9e049cb

Please sign in to comment.