mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-14 09:08:12 +02:00
feat: add read-only Itō compute handoff (#2554)
* feat: add read-only Itō compute handoff * fix(ito): keep handoff portable under CI * test(ito): run npm welcome through Windows shell
This commit is contained in:
parent
a3130f9ebf
commit
7b03a834b3
8 changed files with 830 additions and 1 deletions
55
scripts/lib/ito-environment.js
Normal file
55
scripts/lib/ito-environment.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
|
||||
const SYSTEM_ENVIRONMENT_KEYS = Object.freeze([
|
||||
"CI",
|
||||
"ComSpec",
|
||||
"DISPLAY",
|
||||
"FORCE_COLOR",
|
||||
"HOME",
|
||||
"LANG",
|
||||
"LC_ALL",
|
||||
"NO_COLOR",
|
||||
"PATH",
|
||||
"PATHEXT",
|
||||
"SHELL",
|
||||
"SystemRoot",
|
||||
"TEMP",
|
||||
"TERM",
|
||||
"TMP",
|
||||
"TMPDIR",
|
||||
"USERPROFILE",
|
||||
"WAYLAND_DISPLAY",
|
||||
"WINDIR",
|
||||
"XDG_RUNTIME_DIR",
|
||||
]);
|
||||
|
||||
function copyDefined(source, target, key) {
|
||||
if (typeof source[key] === "string") {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
function createSafeItoEnvironment(source = process.env, options = {}) {
|
||||
const safe = {};
|
||||
for (const key of SYSTEM_ENVIRONMENT_KEYS) {
|
||||
copyDefined(source, safe, key);
|
||||
}
|
||||
for (const [key] of Object.entries(source)) {
|
||||
if (key.startsWith("LC_")) copyDefined(source, safe, key);
|
||||
}
|
||||
|
||||
if (options.includeControls) {
|
||||
copyDefined(source, safe, "ECC_DRY_RUN");
|
||||
copyDefined(source, safe, "NODE_ENV");
|
||||
if (source.NODE_ENV === "test") {
|
||||
copyDefined(source, safe, "ECC_ITO_BROWSER_EXECUTABLE");
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(safe);
|
||||
}
|
||||
|
||||
module.exports = Object.freeze({
|
||||
SYSTEM_ENVIRONMENT_KEYS,
|
||||
createSafeItoEnvironment,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue