mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(task): resolve deno configuration file first from specified --cwd
arg (#15257)
This commit is contained in:
parent
cee3246edb
commit
73504d76b2
2 changed files with 21 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
use crate::args::ConfigFlag;
|
||||
use crate::args::Flags;
|
||||
use crate::args::TaskFlags;
|
||||
use crate::fs_util;
|
||||
use crate::fs_util::canonicalize_path;
|
||||
use crate::fs_util::specifier_parent;
|
||||
use crate::fs_util::specifier_to_file_path;
|
||||
|
@ -449,6 +451,18 @@ impl ConfigFile {
|
|||
return Ok(Some(cf));
|
||||
}
|
||||
}
|
||||
// attempt to resolve the config file from the task subcommand's
|
||||
// `--cwd` when specified
|
||||
if let crate::args::DenoSubcommand::Task(TaskFlags {
|
||||
cwd: Some(path),
|
||||
..
|
||||
}) = &flags.subcommand
|
||||
{
|
||||
let task_cwd = fs_util::canonicalize_path(&PathBuf::from(path))?;
|
||||
if let Some(path) = Self::discover_from(&task_cwd, &mut checked)? {
|
||||
return Ok(Some(path));
|
||||
}
|
||||
};
|
||||
// From CWD walk up to root looking for deno.json or deno.jsonc
|
||||
let cwd = std::env::current_dir()?;
|
||||
Self::discover_from(&cwd, &mut checked)
|
||||
|
|
|
@ -19,6 +19,13 @@ itest!(task_cwd {
|
|||
exit_code: 0,
|
||||
});
|
||||
|
||||
itest!(task_cwd_resolves_config_from_specified_dir {
|
||||
args: "task -q --cwd task",
|
||||
output: "task/task_no_args.out",
|
||||
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(task_non_existent {
|
||||
args: "task --config task/deno.json non_existent",
|
||||
output: "task/task_non_existent.out",
|
||||
|
|
Loading…
Reference in a new issue