mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-22 01:53:24 +01:00
Add isValidPackcageManager() util
This commit is contained in:
parent
cbe5f5b523
commit
f4f2e854d7
2 changed files with 14 additions and 0 deletions
|
@ -4,6 +4,7 @@ import {
|
||||||
checkWorkingDirectory,
|
checkWorkingDirectory,
|
||||||
detectPackageManager,
|
detectPackageManager,
|
||||||
getNpxCmd,
|
getNpxCmd,
|
||||||
|
isValidPackageManager,
|
||||||
semverCompare,
|
semverCompare,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
|
@ -70,3 +71,12 @@ describe("detectPackageManager", () => {
|
||||||
expect(detectPackageManager("test/fixtures/empty")).toBe(null);
|
expect(detectPackageManager("test/fixtures/empty")).toBe(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("isValidPackageManager", () => {
|
||||||
|
expect(isValidPackageManager("npm")).toBe(true);
|
||||||
|
expect(isValidPackageManager("pnpm")).toBe(true);
|
||||||
|
expect(isValidPackageManager("yarn")).toBe(true);
|
||||||
|
|
||||||
|
expect(isValidPackageManager("")).toBe(false);
|
||||||
|
expect(isValidPackageManager("ppnpm")).toBe(false);
|
||||||
|
});
|
||||||
|
|
|
@ -50,3 +50,7 @@ export function detectPackageManager(
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isValidPackageManager(name: string): name is PackageManager {
|
||||||
|
return name === "npm" || name === "yarn" || name === "pnpm";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue