use std::path::Path;
use std::process::Command;
pub(crate) fn detect(dir: &Path) -> bool {
dir.join("Pipfile").exists() || dir.join("Pipfile.lock").exists()
}
pub(crate) fn install_cmd(frozen: bool) -> Command {
let mut c = super::program::command("pipenv");
if frozen {
c.arg("sync");
} else {
c.arg("install");
}
c
}
#[cfg(test)]
mod tests {
use super::install_cmd;
#[test]
fn install_unfrozen_uses_install_subcommand() {
let args: Vec<_> = install_cmd(false)
.get_args()
.map(|arg| arg.to_string_lossy().into_owned())
.collect();
assert_eq!(args, ["install"]);
}
#[test]
fn install_frozen_uses_sync_subcommand() {
let args: Vec<_> = install_cmd(true)
.get_args()
.map(|arg| arg.to_string_lossy().into_owned())
.collect();
assert_eq!(args, ["sync"]);
}
}