mirror of
https://github.com/actions/setup-node.git
synced 2025-04-03 01:49:34 +08:00
feat: install corepack before enabling
This commit is contained in:
parent
dfc689aeba
commit
4c2fa5a76f
|
@ -288,30 +288,37 @@ describe('main tests', () => {
|
|||
it('should not enable corepack when no input', async () => {
|
||||
inputs['corepack'] = '';
|
||||
await main.run();
|
||||
expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack'));
|
||||
expect(getCommandOutputSpy).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('corepack')
|
||||
);
|
||||
});
|
||||
|
||||
it('should not enable corepack when input is "false"', async () => {
|
||||
inputs['corepack'] = 'false';
|
||||
await main.run();
|
||||
expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack'));
|
||||
expect(getCommandOutputSpy).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('corepack')
|
||||
);
|
||||
});
|
||||
|
||||
it('should enable corepack when input is "true"', async () => {
|
||||
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'
|
||||
);
|
||||
|
|
4
dist/cache-save/index.js
vendored
4
dist/cache-save/index.js
vendored
|
@ -88239,12 +88239,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
|
||||
exports.enableCorepack = exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const exec = __importStar(__nccwpck_require__(5236));
|
||||
const io = __importStar(__nccwpck_require__(4994));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(9896));
|
||||
const path_1 = __importDefault(__nccwpck_require__(6928));
|
||||
const cache_utils_1 = __nccwpck_require__(4673);
|
||||
function getNodeVersionFromFile(versionFilePath) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||
|
@ -88345,6 +88346,7 @@ function enableCorepack(input) {
|
|||
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(' ')}`);
|
||||
}
|
||||
});
|
||||
|
|
4
dist/setup/index.js
vendored
4
dist/setup/index.js
vendored
|
@ -97917,12 +97917,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
|
||||
exports.enableCorepack = exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const exec = __importStar(__nccwpck_require__(5236));
|
||||
const io = __importStar(__nccwpck_require__(4994));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(9896));
|
||||
const path_1 = __importDefault(__nccwpck_require__(6928));
|
||||
const cache_utils_1 = __nccwpck_require__(4673);
|
||||
function getNodeVersionFromFile(versionFilePath) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||
|
@ -98023,6 +98024,7 @@ function enableCorepack(input) {
|
|||
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(' ')}`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -115,6 +115,7 @@ export async function enableCorepack(input: string): Promise<void> {
|
|||
const packageManagers = input.split(' ');
|
||||
corepackArgs.push(...packageManagers);
|
||||
}
|
||||
await getCommandOutput('npm i -g corepack');
|
||||
await getCommandOutput(`corepack ${corepackArgs.join(' ')}`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user