mirror of
https://github.com/actions/setup-node.git
synced 2025-04-03 01:49:34 +08:00
fix: removed extra corepack commands
This commit is contained in:
parent
4c2fa5a76f
commit
108e90108c
|
@ -305,23 +305,6 @@ describe('main tests', () => {
|
||||||
inputs['corepack'] = 'true';
|
inputs['corepack'] = 'true';
|
||||||
await main.run();
|
await main.run();
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack');
|
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'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,7 @@ inputs:
|
||||||
cache-dependency-path:
|
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.'
|
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:
|
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'
|
default: 'false'
|
||||||
# TODO: add input to control forcing to pull from cloud or dist.
|
# 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
|
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
||||||
|
|
6
dist/cache-save/index.js
vendored
6
dist/cache-save/index.js
vendored
|
@ -88341,13 +88341,7 @@ exports.unique = unique;
|
||||||
function enableCorepack(input) {
|
function enableCorepack(input) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (input.length && input !== 'false') {
|
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)('npm i -g corepack');
|
||||||
yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
6
dist/setup/index.js
vendored
6
dist/setup/index.js
vendored
|
@ -98019,13 +98019,7 @@ exports.unique = unique;
|
||||||
function enableCorepack(input) {
|
function enableCorepack(input) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (input.length && input !== 'false') {
|
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)('npm i -g corepack');
|
||||||
yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,21 +427,8 @@ steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '18.x'
|
node-version: '22.x'
|
||||||
corepack: true
|
corepack: true
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
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
|
|
||||||
```
|
|
||||||
|
|
|
@ -110,12 +110,6 @@ export const unique = () => {
|
||||||
|
|
||||||
export async function enableCorepack(input: string): Promise<void> {
|
export async function enableCorepack(input: string): Promise<void> {
|
||||||
if (input.length && input !== 'false') {
|
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('npm i -g corepack');
|
||||||
await getCommandOutput(`corepack ${corepackArgs.join(' ')}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user