mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
fix(verify): scrub ambient npm install-policy from verifier child npm environments (#10474)
* fix(verify): scrub ambient npm install-policy from verifier child npm environments * fix(verify): keep caller npm policy for script-enabled commands --------- Co-authored-by: LexLuthorPrimero <1@voidmail.io> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
6 files changed
+46
-16
No files matched your search
@@ -22,6 +22,11 @@ export interface PackageVerifierCommands extends Pick<
|
||||
arguments_: readonly string[],
|
||||
options?: VerifierCommandOptions,
|
||||
): Promise<VerifierCommandOutput>;
|
||||
installWithoutScripts(
|
||||
operation: "ci" | "install",
|
||||
arguments_: readonly string[],
|
||||
options?: VerifierCommandOptions,
|
||||
): Promise<VerifierCommandOutput>;
|
||||
run(
|
||||
command: string,
|
||||
arguments_: readonly string[],
|
||||
@@ -78,6 +83,23 @@ class PackageCommands implements PackageVerifierCommands {
|
||||
return this.exec(invocation.command, invocation.arguments, options);
|
||||
}
|
||||
|
||||
installWithoutScripts(
|
||||
operation: "ci" | "install",
|
||||
arguments_: readonly string[],
|
||||
options: VerifierCommandOptions = {},
|
||||
): Promise<VerifierCommandOutput> {
|
||||
// npm exports this setting to scripts, but rejects it in nested project installs.
|
||||
const environment = Object.fromEntries(
|
||||
Object.entries(options.env ?? process.env).filter(
|
||||
([key]) => key.toLowerCase() !== "npm_config_allow_scripts",
|
||||
),
|
||||
);
|
||||
return this.execNpm([operation, "--ignore-scripts", ...arguments_], {
|
||||
...options,
|
||||
env: environment,
|
||||
});
|
||||
}
|
||||
|
||||
async run(
|
||||
command: string,
|
||||
arguments_: readonly string[],
|
||||
|
||||
@@ -16,11 +16,9 @@ export async function installCanaryPackage(
|
||||
commands,
|
||||
) {
|
||||
const prefix = join(workspace, "installed");
|
||||
await commands.exec(
|
||||
"npm",
|
||||
await commands.installWithoutScripts(
|
||||
"install",
|
||||
[
|
||||
"install",
|
||||
"--ignore-scripts",
|
||||
"--no-save",
|
||||
"--no-package-lock",
|
||||
"--no-audit",
|
||||
|
||||
@@ -61,8 +61,9 @@ export async function verifyPackagePack({ root, workspace, commands }) {
|
||||
`${JSON.stringify(shrinkwrap, null, 2)}\n`,
|
||||
);
|
||||
// Materialize exactly the locked runtime tree without executing installers.
|
||||
await commands.execNpm(
|
||||
["ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund"],
|
||||
await commands.installWithoutScripts(
|
||||
"ci",
|
||||
["--omit=dev", "--no-audit", "--no-fund"],
|
||||
{ cwd: stagingDirectory },
|
||||
);
|
||||
if (packageJson.dependencies?.["@lydell/node-pty"] !== undefined) {
|
||||
|
||||
Reference in new issue
Block a user