Maintain the naming of the env vars

This commit is contained in:
Félix Saparelli 2021-12-29 21:36:42 +13:00
parent d39ffed51e
commit d0bb14f39c
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474
6 changed files with 19 additions and 19 deletions

View file

@ -137,7 +137,7 @@ pub fn get_args(tagged_filterer: bool) -> Result<ArgMatches<'static>> {
.long("no-shell"))
.arg(Arg::with_name("no-environment")
.help_heading(Some(OPTSET_OUTPUT))
.help("Do not set WATCHEXEC_* environment variables for the command")
.help("Do not set WATCHEXEC_*_PATH environment variables for the command")
.long("no-environment"))
.arg(Arg::with_name("no-process-group")
.help_heading(Some(OPTSET_COMMAND))

View file

@ -202,7 +202,7 @@ pub fn runtime(args: &ArgMatches<'static>) -> Result<RuntimeConfig> {
let envs = summarise_events_to_env(prespawn.events.iter());
if let Some(mut command) = prespawn.command().await {
for (k, v) in envs {
command.env(format!("WATCHEXEC_{}", k), v);
command.env(format!("WATCHEXEC_{}_PATH", k), v);
}
}
}

View file

@ -13,7 +13,7 @@ FLAGS:
-c, --clear Clear screen before executing command
-h, --help Prints help information
--no-default-ignore Skip auto-ignoring of commonly ignored globs
--no-environment Do not set WATCHEXEC_* environment variables for the command
--no-environment Do not set WATCHEXEC_*_PATH environment variables for the command
--no-global-ignore Skip auto-loading of global or environment-wide ignore files
--no-meta Ignore metadata changes
--no-process-group Do not use a process group when running the command

View file

@ -13,7 +13,7 @@ FLAGS:
-c, --clear Clear screen before executing command
-h, --help Prints help information
--no-default-ignore Skip auto-ignoring of commonly ignored globs
--no-environment Do not set WATCHEXEC_* environment variables for the command
--no-environment Do not set WATCHEXEC_*_PATH environment variables for the command
--no-global-ignore Skip auto-loading of global or environment-wide ignore files
--no-meta Ignore metadata changes
--no-process-group Do not use a process group when running the command

View file

@ -60,7 +60,7 @@ where
/// - `RENAMED` -> `Modify(Name(_))`
/// - `WRITTEN` -> `Modify(Data(_))`, `Access(Close(Write))`
/// - `OTHERWISE_CHANGED` -> anything else
/// - plus `COMMON_PATH` with the common prefix of all paths (even if there's only one path).
/// - plus `COMMON` with the common prefix of all paths (even if there's only one path).
///
/// It ignores non-path events and pathed events without event kind. Multiple events are sorted in
/// byte order and joined with the platform-specific path separator (`:` for unix, `;` for Windows).
@ -158,7 +158,7 @@ pub fn summarise_events_to_env<'events>(
.collect();
if let Some(common_path) = common_path {
res.insert("COMMON_PATH", common_path.into_os_string());
res.insert("COMMON", common_path.into_os_string());
}
res

View file

@ -47,7 +47,7 @@ fn single_created() {
summarise_events_to_env(&events),
HashMap::from([
("CREATED", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -62,7 +62,7 @@ fn single_meta() {
summarise_events_to_env(&events),
HashMap::from([
("META_CHANGED", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -74,7 +74,7 @@ fn single_removed() {
summarise_events_to_env(&events),
HashMap::from([
("REMOVED", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -89,7 +89,7 @@ fn single_renamed() {
summarise_events_to_env(&events),
HashMap::from([
("RENAMED", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -104,7 +104,7 @@ fn single_written() {
summarise_events_to_env(&events),
HashMap::from([
("WRITTEN", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -116,7 +116,7 @@ fn single_otherwise() {
summarise_events_to_env(&events),
HashMap::from([
("OTHERWISE_CHANGED", OsString::from("file.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -149,7 +149,7 @@ fn all_types_once() {
("RENAMED", OsString::from("rename.txt")),
("WRITTEN", OsString::from("modify.txt")),
("OTHERWISE_CHANGED", OsString::from("any.txt")),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -178,7 +178,7 @@ fn single_type_multipath() {
+ "sub/folder.txt"
)
),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -196,7 +196,7 @@ fn single_type_divergent_paths() {
"CREATED",
OsString::from("".to_string() + "dom/folder.txt" + ENV_SEP + "sub/folder.txt")
),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -223,7 +223,7 @@ fn multitype_multipath() {
("META_CHANGED", OsString::from("sub/folder.txt"),),
("REMOVED", OsString::from("dom/folder.txt"),),
("OTHERWISE_CHANGED", OsString::from("deeper/sub/folder.txt"),),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -251,7 +251,7 @@ fn multiple_paths_in_one_event() {
"OTHERWISE_CHANGED",
OsString::from("".to_string() + "one.txt" + ENV_SEP + "two.txt")
),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -277,7 +277,7 @@ fn mixed_non_paths_events() {
"OTHERWISE_CHANGED",
OsString::from("".to_string() + "one.txt" + ENV_SEP + "two.txt")
),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}
@ -318,7 +318,7 @@ fn multipath_is_sorted() {
+ "c.txt" + ENV_SEP + "ᄁ.txt"
)
),
("COMMON_PATH", ospath("")),
("COMMON", ospath("")),
])
);
}