* Fix workflow * Trigger * [auto] Update compiled version * [auto] Commit modules * Push Windows changes * Fix * [auto] Update compiled version * Try removing cwd * [auto] Update compiled version * Try with path module * [auto] Update compiled version * Fix path * [auto] Update compiled version * Use raw path * [auto] Update compiled version * Other path * [auto] Update compiled version * Avoid @action/exec * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * Try with shelljs * [auto] Update compiled version * Fix my stupidity * Copy scripts to local dir * [auto] Update compiled version * Still use path * [auto] Update compiled version * Delete entrypoint.sh * [auto] Update compiled version * Make file executable * [auto] Update compiled version * Try using bash * [auto] Update compiled version
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];
|
|
|
|
function specifierIncluded(specifier) {
|
|
var parts = specifier.split(' ');
|
|
var op = parts.length > 1 ? parts[0] : '=';
|
|
var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
|
|
|
|
for (var i = 0; i < 3; ++i) {
|
|
var cur = Number(current[i] || 0);
|
|
var ver = Number(versionParts[i] || 0);
|
|
if (cur === ver) {
|
|
continue; // eslint-disable-line no-restricted-syntax, no-continue
|
|
}
|
|
if (op === '<') {
|
|
return cur < ver;
|
|
} else if (op === '>=') {
|
|
return cur >= ver;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return op === '>=';
|
|
}
|
|
|
|
function matchesRange(range) {
|
|
var specifiers = range.split(/ ?&& ?/);
|
|
if (specifiers.length === 0) { return false; }
|
|
for (var i = 0; i < specifiers.length; ++i) {
|
|
if (!specifierIncluded(specifiers[i])) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function versionIncluded(specifierValue) {
|
|
if (typeof specifierValue === 'boolean') { return specifierValue; }
|
|
if (specifierValue && typeof specifierValue === 'object') {
|
|
for (var i = 0; i < specifierValue.length; ++i) {
|
|
if (matchesRange(specifierValue[i])) { return true; }
|
|
}
|
|
return false;
|
|
}
|
|
return matchesRange(specifierValue);
|
|
}
|
|
|
|
var data = require('./core.json');
|
|
|
|
var core = {};
|
|
for (var mod in data) { // eslint-disable-line no-restricted-syntax
|
|
if (Object.prototype.hasOwnProperty.call(data, mod)) {
|
|
core[mod] = versionIncluded(data[mod]);
|
|
}
|
|
}
|
|
module.exports = core;
|