1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2025-03-31 22:30:57 +00:00

fix: removed extra corepack commands

This commit is contained in:
Jacob Parish 2025-03-25 10:02:05 -05:00
parent 4c2fa5a76f
commit 108e90108c
6 changed files with 2 additions and 50 deletions

View file

@ -305,23 +305,6 @@ describe('main tests', () => {
inputs['corepack'] = 'true';
await main.run();
expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack');
expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable');
});
it('should enable corepack with a single package manager', async () => {
inputs['corepack'] = 'npm';
await main.run();
expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack');
expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable npm');
});
it('should enable corepack with multiple package managers', async () => {
inputs['corepack'] = 'npm yarn';
await main.run();
expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack');
expect(getCommandOutputSpy).toHaveBeenCalledWith(
'corepack enable npm yarn'
);
});
});
});

View file

@ -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: 'Used to specify whether to enable Corepack. Set to true to enable all package managers or set it to one or more package manager names separated by a space. Supported package manager names: npm, yarn, pnpm.'
description: 'Used to specify whether to enable Corepack.'
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

View file

@ -88341,13 +88341,7 @@ exports.unique = unique;
function enableCorepack(input) {
return __awaiter(this, void 0, void 0, function* () {
if (input.length && input !== 'false') {
const corepackArgs = ['enable'];
if (input !== 'true') {
const packageManagers = input.split(' ');
corepackArgs.push(...packageManagers);
}
yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack');
yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`);
}
});
}

6
dist/setup/index.js vendored
View file

@ -98019,13 +98019,7 @@ exports.unique = unique;
function enableCorepack(input) {
return __awaiter(this, void 0, void 0, function* () {
if (input.length && input !== 'false') {
const corepackArgs = ['enable'];
if (input !== 'true') {
const packageManagers = input.split(' ');
corepackArgs.push(...packageManagers);
}
yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack');
yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`);
}
});
}

View file

@ -427,21 +427,8 @@ steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '22.x'
corepack: true
- name: Install dependencies
run: yarn install --immutable
```
You can also pass package manager names separated by a space to enable corepack for specific package managers only.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
corepack: yarn pnpm
- name: Install dependencies
run: yarn install --immutable
```

View file

@ -110,12 +110,6 @@ export const unique = () => {
export async function enableCorepack(input: string): Promise<void> {
if (input.length && input !== 'false') {
const corepackArgs = ['enable'];
if (input !== 'true') {
const packageManagers = input.split(' ');
corepackArgs.push(...packageManagers);
}
await getCommandOutput('npm i -g corepack');
await getCommandOutput(`corepack ${corepackArgs.join(' ')}`);
}
}