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

Commit

Permalink
test: test pnpm packages only on node >= 14.19 (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
kldzj authored May 5, 2022
1 parent 8cd98af commit 193b778
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
8 changes: 1 addition & 7 deletions test/test-10-pnpm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');

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

Expand Down
8 changes: 1 addition & 7 deletions test/test-11-pnpm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');

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

Expand Down
4 changes: 1 addition & 3 deletions test/test-12-compression-node-opcua/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const utils = require('../utils.js');
assert(!module.parent);
assert(__dirname === process.cwd());

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

Expand Down
19 changes: 19 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,22 @@ module.exports.filesAfter = function (b, n) {
module.exports.vacuum.sync(ni);
}
};

module.exports.shouldSkipPnpm = function () {
const REQUIRED_MAJOR_VERSION = 14;
const REQUIRED_MINOR_VERSION = 19;

const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10);
const MINOR_VERSION = parseInt(process.version.match(/v[0-9]+\.([0-9]+)/)[1], 10);

const isDisallowedMajor = MAJOR_VERSION < REQUIRED_MAJOR_VERSION
const isDisallowedMinor = MAJOR_VERSION === REQUIRED_MAJOR_VERSION && MINOR_VERSION < REQUIRED_MINOR_VERSION;
if (isDisallowedMajor || isDisallowedMinor) {
const need = `${REQUIRED_MAJOR_VERSION}.${REQUIRED_MINOR_VERSION}`;
const got = `${MAJOR_VERSION}.${MINOR_VERSION}`;
console.log(`skiping test as it requires nodejs >= ${need} and got ${got}`);
return true;
}

return false;
}

0 comments on commit 193b778

Please sign in to comment.