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