fn run_npm_install(dir: &PathBuf) -> Result<(), failure::Error> {
    let flock_path = dir.join(&".install.lock");
    let flock = File::create(&flock_path)?;
    // avoid running multiple {npm install} at the same time (eg. in tests)
    flock.lock_exclusive()?;

    if !dir.join("node_modules").exists() {
        let mut command = build_npm_command();
        command.current_dir(dir.clone());
        command.arg("install");
        log::info!("Running {:?} in directory {:?}", command, dir);

        let status = command.status()?;

        if !status.success() {
            failure::bail!("failed to execute `{:?}`: exited with {}", command, status)
        }
    } else {
        log::info!("skipping npm install because node_modules exists");
    }

    // TODO: (sven) figure out why the file doesn't exist in some cases
    if flock_path.exists() {
        fs::remove_file(&flock_path)?;
    }
    flock.unlock()?;

    Ok(())
}
// Run {npm install} in the specified directory. Skips the install if a
// {node_modules} is found in the directory.
Run {npm install} in the specified directory. Skips the install if a
{node_modules} is found in the directory.
Run { npm install } in the specified directory . Skips the install if a { node_modules } is found in the directory .
fn run_npm_install(dir: &PathBuf) -> Result<(), failure::Error> {
    let flock_path = dir.join(&".install.lock");
    let flock = File::create(&flock_path)?;
    // avoid running multiple {npm install} at the same time (eg. in tests)
    flock.lock_exclusive()?;
    if !dir.join("node_modules").exists() {
        let mut command = build_npm_command();
        command.current_dir(dir.clone());
        command.arg("install");
        log::info!("Running {:?} in directory {:?}", command, dir);
        let status = command.status()?;
        if !status.success() {
            failure::bail!("failed to execute `{:?}`: exited with {}", command, status)
        }
    } else {
        log::info!("skipping npm install because node_modules exists");
    }
    // TODO: (sven) figure out why the file doesn't exist in some cases
    if flock_path.exists() {
        fs::remove_file(&flock_path)?;
    }
    flock.unlock()?;
    Ok(())
}
fn run_npm_install ( dir : & PathBuf ) -> Result < ( ) , failure :: Error > { let flock_path = dir . join ( & " " ) ; let flock = File :: create ( & flock_path ) ? ; // avoid running multiple {npm install} at the same time (eg. in tests) flock . lock_exclusive ( ) ? ; if ! dir . join ( " " ) . exists ( ) { let mut command = build_npm_command ( ) ; command . current_dir ( dir . clone ( ) ) ; command . arg ( " " ) ; log :: info ! ( " " command dir ) ; let status = command . status ( ) ? ; if ! status . success ( ) { failure :: bail ! ( " " command status ) } } else { log :: info ! ( " " ) ; } // TODO: (sven) figure out why the file doesn't exist in some cases if flock_path . exists ( ) { fs :: remove_file ( & flock_path ) ? ; } flock . unlock ( ) ? ; Ok ( ( ) ) }
Run {npm install} in the specified directory.
Run { npm install } in the specified directory .
dir
&PathBuf