Add packageManager setting

This commit is contained in:
Han Yeong-woo 2023-09-02 06:34:18 +09:00
parent f2e4cda4dd
commit a009342d77
No known key found for this signature in database
GPG key ID: A46E340CB4E4D6AD
2 changed files with 9 additions and 0 deletions

View file

@ -41,3 +41,6 @@ inputs:
vars:
description: "A string of environment variable names, separated by newlines. These will be bound to your Worker using the values of matching environment variables declared in `env` of this workflow."
required: false
packageManager:
description: "The name of the package manager to install and run wrangler. If not provided, it will be detected via the lock file. Valid values: [npm, pnpm, yarn]"
required: false

View file

@ -14,6 +14,7 @@ import {
PackageManager,
checkWorkingDirectory,
detectPackageManager,
isValidPackageManager,
semverCompare,
} from "./utils";
const execAsync = util.promisify(exec);
@ -53,9 +54,14 @@ const config = {
VARS: getMultilineInput("vars"),
COMMANDS: getMultilineInput("command"),
QUIET_MODE: getBooleanInput("quiet"),
PACKAGE_MANAGER: getInput("packageManager"),
} as const;
function realPackageManager(): PackageManager {
if (isValidPackageManager(config.PACKAGE_MANAGER)) {
return config.PACKAGE_MANAGER;
}
const packageManager = detectPackageManager(config.workingDirectory);
if (packageManager !== null) {
return packageManager;