mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-24 10:58:37 +00:00
fix(scripts): reject short flag shrinkwrap refs
This commit is contained in:
@@ -1170,7 +1170,7 @@ function listCheckChangedPaths() {
|
||||
}
|
||||
}
|
||||
|
||||
function resolvePackageDirs(args) {
|
||||
export function resolvePackageDirs(args) {
|
||||
const packageDirs = [];
|
||||
const check = args.includes("--check");
|
||||
const all = args.includes("--all");
|
||||
@@ -1199,7 +1199,7 @@ function resolvePackageDirs(args) {
|
||||
}
|
||||
if (arg === "--package-dir") {
|
||||
const value = args[index + 1];
|
||||
if (!value || value.startsWith("--")) {
|
||||
if (!value || value.startsWith("-")) {
|
||||
throw new Error("--package-dir requires a package directory.");
|
||||
}
|
||||
packageDirs.push(path.resolve(ROOT_DIR, value));
|
||||
@@ -1208,7 +1208,7 @@ function resolvePackageDirs(args) {
|
||||
}
|
||||
if (arg === "--base" || arg === "--head") {
|
||||
const value = args[index + 1];
|
||||
if (!value || value.startsWith("--")) {
|
||||
if (!value || value.startsWith("-")) {
|
||||
throw new Error(`${arg} requires a git ref.`);
|
||||
}
|
||||
index += 1;
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
pnpmLockOverrideVersionForVersions,
|
||||
parsePnpmPackageKey,
|
||||
parseLockPackagePath,
|
||||
resolvePackageDirs,
|
||||
restoreCurrentPnpmLockedPackages,
|
||||
shouldUseLegacyPeerDepsForShrinkwrap,
|
||||
shrinkwrapPackageDirsForChangedPaths,
|
||||
@@ -57,6 +58,18 @@ describe("generate-npm-shrinkwrap", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects short flag package selectors before resolving shrinkwrap targets", () => {
|
||||
expect(() => resolvePackageDirs(["--package-dir", "-h"])).toThrow(
|
||||
"--package-dir requires a package directory.",
|
||||
);
|
||||
expect(() => resolvePackageDirs(["--changed", "--base", "-h"])).toThrow(
|
||||
"--base requires a git ref.",
|
||||
);
|
||||
expect(() => resolvePackageDirs(["--changed", "--head", "-h"])).toThrow(
|
||||
"--head requires a git ref.",
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts strict npm shrinkwrap command timeout and buffer overrides", () => {
|
||||
expect(
|
||||
createNpmShrinkwrapExecOptions({ command: "npm", args: ["install"] }, "/tmp/package", {
|
||||
|
||||
Reference in New Issue
Block a user