Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option to Enable corepack #546

Closed
wants to merge 15 commits into from
Prev Previous commit
Next Next commit
add code from simbo/setup-node:corepack
BeeeQueue/setup-node#2
  • Loading branch information
beeequeue committed Oct 7, 2022
commit 4ae98e59c8b68d5c4aedc5b30261a6a958ebe3a1
13 changes: 2 additions & 11 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('setup-node', () => {
platSpy.mockImplementation(() => os['platform']);
archSpy = jest.spyOn(osm, 'arch');
archSpy.mockImplementation(() => os['arch']);
execSpy = jest.spyOn(cp, 'execSync');

// @actions/tool-cache
findSpy = jest.spyOn(tc, 'find');
Expand Down Expand Up @@ -110,6 +109,7 @@ describe('setup-node', () => {
// @actions/exec
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
execSpy = jest.spyOn(cp, 'execSync');
});

afterEach(() => {
Expand Down Expand Up @@ -397,18 +397,9 @@ describe('setup-node', () => {
}, 100000);

it('enables corepack if specified', async () => {
os.platform = 'linux';
os.arch = 'x64';

inputs['node-version'] = '16';
inputs['corepack'] = 'true';

const toolPath = path.normalize('/cache/node/16.17.0/x64');
findSpy.mockReturnValue(toolPath);
await main.run();

// It seems to call it with the absolute path to corepack, so we easily use `toHaveBeenCalledWith`
expect(cnSpy.mock.calls[3][0]).toContain('corepack enable');
expect(execSpy).toHaveBeenCalledWith('corepack', ['enable']);
});

describe('check-latest flag', () => {
Expand Down