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

feat: add volta as node-version-file #532

Merged
merged 21 commits into from Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions __tests__/data/package.json
@@ -0,0 +1,11 @@
{
"name": "test",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "echo test"
},
"volta": {
"node": "16.15.1"
}
}
21 changes: 21 additions & 0 deletions __tests__/installer.test.ts
Expand Up @@ -584,6 +584,27 @@ describe('setup-node', () => {
);
});

it('reads node-version-file if provided with volta', async () => {
// Arrange
const expectedVersionSpec = '16.15.1';
const versionFile = 'package.json';
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
inputs['node-version-file'] = 'volta';

existsSpy.mockImplementationOnce(
input => input === path.join(__dirname, 'data', versionFile)
);
// Act
await main.run();

// Assert
expect(existsSpy).toHaveBeenCalledTimes(1);
expect(existsSpy).toHaveReturnedWith(true);
expect(logSpy).toHaveBeenCalledWith(
`Resolved ${versionFile} as ${expectedVersionSpec}`
);
});

it('both node-version-file and node-version are provided', async () => {
inputs['node-version'] = '12';
const versionSpec = 'v14';
Expand Down