Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 193b778

Browse files
authored
test: test pnpm packages only on node >= 14.19 (#1613)
1 parent 8cd98af commit 193b778

4 files changed

Lines changed: 22 additions & 17 deletions

File tree

test/test-10-pnpm/main.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ const path = require('path');
77
const assert = require('assert');
88
const utils = require('../utils.js');
99

10-
// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
11-
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
12-
if (MAJOR_VERSION < 12) {
13-
console.log(
14-
'skiping test as it requires nodejs >= 12 and got',
15-
MAJOR_VERSION
16-
);
10+
if (utils.shouldSkipPnpm()) {
1711
return;
1812
}
1913

test/test-11-pnpm/main.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ const path = require('path');
77
const assert = require('assert');
88
const utils = require('../utils.js');
99

10-
// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
11-
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
12-
if (MAJOR_VERSION < 12) {
13-
console.log(
14-
'skiping test as it requires nodejs >= 12 and got',
15-
MAJOR_VERSION
16-
);
10+
if (utils.shouldSkipPnpm()) {
1711
return;
1812
}
1913

test/test-12-compression-node-opcua/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const utils = require('../utils.js');
1616
assert(!module.parent);
1717
assert(__dirname === process.cwd());
1818

19-
// ignore this test if nodejs <= 10 , as recent version of PNPM do not support nodejs=10
20-
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
21-
if (MAJOR_VERSION < 12) {
19+
if (utils.shouldSkipPnpm()) {
2220
return;
2321
}
2422

test/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,22 @@ module.exports.filesAfter = function (b, n) {
165165
module.exports.vacuum.sync(ni);
166166
}
167167
};
168+
169+
module.exports.shouldSkipPnpm = function () {
170+
const REQUIRED_MAJOR_VERSION = 14;
171+
const REQUIRED_MINOR_VERSION = 19;
172+
173+
const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
174+
const MINOR_VERSION = parseInt(process.version.match(/v[0-9]+\.([0-9]+)/)[1], 10);
175+
176+
const isDisallowedMajor = MAJOR_VERSION < REQUIRED_MAJOR_VERSION
177+
const isDisallowedMinor = MAJOR_VERSION === REQUIRED_MAJOR_VERSION && MINOR_VERSION < REQUIRED_MINOR_VERSION;
178+
if (isDisallowedMajor || isDisallowedMinor) {
179+
const need = `${REQUIRED_MAJOR_VERSION}.${REQUIRED_MINOR_VERSION}`;
180+
const got = `${MAJOR_VERSION}.${MINOR_VERSION}`;
181+
console.log(`skiping test as it requires nodejs >= ${need} and got ${got}`);
182+
return true;
183+
}
184+
185+
return false;
186+
}

0 commit comments

Comments
 (0)