Skip to content

Commit

Permalink
Drop unsupported nodejs versions (v10 & v12) (#44)
Browse files Browse the repository at this point in the history
* update min required nodejs veresion

* update GH actions node.js vesions to test against

* update json error messages for newer nodejs version
  • Loading branch information
antonk52 authored Nov 18, 2023
1 parent 6f815f4 commit 0d3113f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v1
Expand All @@ -22,7 +22,6 @@ jobs:
- name: build
run: npm run build
- name: check codestyle
if: matrix.node-version != '10.x'
run: npm run lint
- name: tests
run: npm run test
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"typescript": "4.4.4"
},
"engines": {
"node": ">=10"
"node": ">=14"
}
}
26 changes: 22 additions & 4 deletions src/spec/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ beforeEach(() => {
jest.clearAllMocks();
});

const isNodeV20orNewer = parseInt(process.versions.node, 10) >= 20;

describe('options', () => {
const dirname = path.join(__dirname, 'load');

Expand Down Expand Up @@ -1179,7 +1181,11 @@ describe('lilconfigSync', () => {
*/
expect(() => {
lilconfigSync('test-app').load(relativeFilepath);
}).toThrowError('Unexpected token / in JSON at position 22');
}).toThrowError(
isNodeV20orNewer
? `Expected ',' or '}' after property value in JSON at position 22`
: 'Unexpected token / in JSON at position 22',
);

expect(() => {
cosmiconfigSync('test-app').load(relativeFilepath);
Expand Down Expand Up @@ -1245,7 +1251,11 @@ describe('lilconfigSync', () => {

expect(() => {
lilconfigSync('test-app').load(relativeFilepath);
}).toThrowError('Unexpected token # in JSON at position 2');
}).toThrowError(
isNodeV20orNewer
? `Unexpected non-whitespace character after JSON at position 2`
: 'Unexpected token # in JSON at position 2',
);
expect(() => {
cosmiconfigSync('test-app').load(relativeFilepath);
}).toThrowError(`YAML Error in ${filepath}`);
Expand Down Expand Up @@ -1606,7 +1616,11 @@ describe('lilconfig', () => {
*/
expect(
lilconfig('test-app').load(relativeFilepath),
).rejects.toThrowError('Unexpected token / in JSON at position 22');
).rejects.toThrowError(
isNodeV20orNewer
? `Expected ',' or '}' after property value in JSON at position 22`
: 'Unexpected token / in JSON at position 22',
);

expect(
cosmiconfig('test-app').load(relativeFilepath),
Expand Down Expand Up @@ -1678,7 +1692,11 @@ describe('lilconfig', () => {

await expect(
lilconfig('test-app').load(relativeFilepath),
).rejects.toThrowError('Unexpected token # in JSON at position 2');
).rejects.toThrowError(
isNodeV20orNewer
? `Unexpected non-whitespace character after JSON at position 2`
: 'Unexpected token # in JSON at position 2',
);
await expect(
cosmiconfig('test-app').load(relativeFilepath),
).rejects.toThrowError(`YAML Error in ${filepath}`);
Expand Down

0 comments on commit 0d3113f

Please sign in to comment.