-
-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the system default Node.js to check package compatibility (#…
- Loading branch information
Showing
10 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@pnpm/package-is-installable": patch | ||
"pnpm": patch | ||
--- | ||
|
||
Use the system default Node.js version to check package compatibility [#3785](https://github.com/pnpm/pnpm/issues/3785). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/package-is-installable/src/getSystemNodeVersion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import mem from 'mem' | ||
import * as execa from 'execa' | ||
|
||
export function getSystemNodeVersionNonCached () { | ||
if (process['pkg'] != null) { | ||
return execa.sync('node', ['--version']).stdout.toString() | ||
} | ||
return process.version | ||
} | ||
|
||
export const getSystemNodeVersion = mem(getSystemNodeVersionNonCached) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/package-is-installable/test/getSystemNodeVersion.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getSystemNodeVersionNonCached } from '@pnpm/package-is-installable/lib/getSystemNodeVersion' | ||
import * as execa from 'execa' | ||
|
||
jest.mock('execa', () => ({ | ||
sync: jest.fn(() => ({ | ||
stdout: 'v10.0.0', | ||
})), | ||
})) | ||
|
||
test('getSystemNodeVersion() executed from an executable pnpm CLI', () => { | ||
process['pkg'] = {} | ||
expect(getSystemNodeVersionNonCached()).toBe('v10.0.0') | ||
expect(execa.sync).toHaveBeenCalledWith('node', ['--version']) | ||
}) | ||
|
||
test('getSystemNodeVersion() from a non-executable pnpm CLI', () => { | ||
delete process['pkg'] | ||
expect(getSystemNodeVersionNonCached()).toBe(process.version) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.