use std::path::Path;
use super::common::{read_manifest, report_installed, sync};
use super::Res;
use crate::install::node_modules;
use crate::package_json::lock::write_from_manifest;
pub(super) fn run(dir: &Path, lockfile_only: bool, no_lockfile: bool) -> Res {
if no_lockfile {
report_installed(&node_modules(&dir.join("package.json"), dir)?);
return Ok(());
}
if lockfile_only {
let lockfile = dir.join("package-lock.json");
write_from_manifest(&dir.join("package.json"), &lockfile)?;
println!("wrote {}", lockfile.display());
return Ok(());
}
let doc = read_manifest(dir)?;
sync(dir, &doc)
}