diff --git a/.idea/auto_sync.xml b/.idea/auto_sync.xml new file mode 100644 index 0000000..e639e44 --- /dev/null +++ b/.idea/auto_sync.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 9d203f6..1266ae4 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ Installs a global `cargo` dependency if it isn't already installed. - **version**: Version to install, defaults to latest - **release**: Boolean, set to true to install a release version instead of debug - **force-version**: Boolean, set to true to force the given version if a different version is installed +- **binary-name**: If the binary name is different from the package name, specify it here (used for version checks) diff --git a/action.yml b/action.yml index abec9ba..89f0621 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,8 @@ inputs: name: required: true description: Package name + binary-name: + description: Binary name if different from package name version: description: Version to install. Defaults to latest release: diff --git a/index.js b/index.js index 59049f7..012ce0a 100644 --- a/index.js +++ b/index.js @@ -3,11 +3,12 @@ const {spawnSync} = require('node:child_process'); try { const name = getInput('name', {required: true}); + const binaryName = getInput('binary-name') || name; const version = getInput('version'); const release = getBooleanInput('release'); const forceVersion = getBooleanInput('force-version'); - const alreadyInstalled = getInstalledVersion(name); + const alreadyInstalled = getInstalledVersion(name, binaryName); if (alreadyInstalled && (!forceVersion || (version && alreadyInstalled === version))) { info(`Already installed ${name}@${alreadyInstalled}`); @@ -42,14 +43,14 @@ try { setFailed(e); } -function getInstalledVersion(pkg) { +function getInstalledVersion(pkg, binaryName) { let app; const args = ['--version']; if (pkg.match(/^cargo-[\w-_]+$/)) { app = 'cargo'; args.unshift(pkg.slice('cargo-'.length)); } else { - app = pkg; + app = binaryName; } const res = spawnSync(app, args, {