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;
use crate::registry::{PackumentDetail, Registry};
pub(super) fn run(
dir: &Path,
lockfile_only: bool,
no_lockfile: bool,
detail: PackumentDetail,
) -> 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,
&Registry::npm().with_detail(detail),
)?;
println!("wrote {}", lockfile.display());
return Ok(());
}
let doc = read_manifest(dir)?;
sync(dir, &doc, detail)
}