mirror of
https://github.com/actions/setup-node.git
synced 2025-03-31 00:00:10 +08:00
feat: allow specifying a version
This commit is contained in:
parent
4478bd4702
commit
aa9724272b
@ -301,10 +301,28 @@ describe('main tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should enable corepack when input is "true"', async () => {
|
||||
it('should install latest corepack when input is "true"', async () => {
|
||||
inputs['corepack'] = 'true';
|
||||
await main.run();
|
||||
expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack');
|
||||
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||
'npm i -g corepack@latest'
|
||||
);
|
||||
});
|
||||
|
||||
it('should install latest corepack when input is "latest"', async () => {
|
||||
inputs['corepack'] = 'latest';
|
||||
await main.run();
|
||||
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||
'npm i -g corepack@latest'
|
||||
);
|
||||
});
|
||||
|
||||
it('should install a specific version of corepack when specified', async () => {
|
||||
inputs['corepack'] = '0.32.0';
|
||||
await main.run();
|
||||
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||
'npm i -g corepack@0.32.0'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ inputs:
|
||||
cache-dependency-path:
|
||||
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
||||
corepack:
|
||||
description: 'Enables Corepack which allows the use of other package managers.'
|
||||
description: 'Enables Corepack which allows the use of other package managers. Can provide a version string to install a specific version.'
|
||||
default: 'false'
|
||||
# TODO: add input to control forcing to pull from cloud or dist.
|
||||
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
||||
|
3
dist/cache-save/index.js
vendored
3
dist/cache-save/index.js
vendored
@ -88341,7 +88341,8 @@ exports.unique = unique;
|
||||
function enableCorepack(input) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (input.length && input !== 'false') {
|
||||
yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack');
|
||||
const version = input === 'true' ? 'latest' : input;
|
||||
yield (0, cache_utils_1.getCommandOutput)(`npm i -g corepack@${version}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
3
dist/setup/index.js
vendored
3
dist/setup/index.js
vendored
@ -98019,7 +98019,8 @@ exports.unique = unique;
|
||||
function enableCorepack(input) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (input.length && input !== 'false') {
|
||||
yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack');
|
||||
const version = input === 'true' ? 'latest' : input;
|
||||
yield (0, cache_utils_1.getCommandOutput)(`npm i -g corepack@${version}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -432,3 +432,16 @@ steps:
|
||||
- name: Install dependencies
|
||||
run: yarn install --immutable
|
||||
```
|
||||
|
||||
You can also pass a version string to install a specific version of corepack.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18.x'
|
||||
corepack: '0.32.0'
|
||||
- name: Install dependencies
|
||||
run: yarn install --immutable
|
||||
```
|
||||
|
@ -110,6 +110,7 @@ export const unique = () => {
|
||||
|
||||
export async function enableCorepack(input: string): Promise<void> {
|
||||
if (input.length && input !== 'false') {
|
||||
await getCommandOutput('npm i -g corepack');
|
||||
const version = input === 'true' ? 'latest' : input;
|
||||
await getCommandOutput(`npm i -g corepack@${version}`);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user