Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');
const fetch = require('pkg-fetch');
assert(!module.parent);
assert(__dirname === process.cwd());
const host = 'node' + process.version.match(/^v(\d+)/)[1];
const target = process.argv[2] || host;
let right;
fetch.need({
nodeRange: target,
platform: fetch.system.hostPlatform,
arch: fetch.system.hostArch
}).then(function (needed) {
right = utils.spawn.sync(
'./' + path.basename(needed),
[ '--expose-gc',
'-e', 'if (global.gc) console.log("ok");' ],
{ cwd: path.dirname(needed),
env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' } }
);
assert.equal(right, 'ok\n');
}).catch(function (error) {
console.error(`> ${error.message}`);
process.exit(2);
});
const assert = require('assert');
const utils = require('../utils.js');
const fetch = require('pkg-fetch');
assert(!module.parent);
assert(__dirname === process.cwd());
const host = 'node' + process.version.match(/^v(\d+)/)[1];
const target = process.argv[2] || host;
let right;
fetch.need({
nodeRange: target,
platform: fetch.system.hostPlatform,
arch: fetch.system.hostArch
}).then(function (needed) {
right = utils.spawn.sync(
'./' + path.basename(needed),
[ '--expose-gc',
'-e', 'if (global.gc) console.log("ok");' ],
{ cwd: path.dirname(needed),
env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' } }
);
assert.equal(right, 'ok\n');
}).catch(function (error) {
console.error(`> ${error.message}`);
process.exit(2);
});
#!/usr/bin/env node
'use strict';
const assert = require('assert');
const fetch = require('pkg-fetch');
const dontBuild = require('pkg-fetch/lib-es5/upload.js').dontBuild;
const knownPlatforms = fetch.system.knownPlatforms;
const items = [];
function nodeRangeToNodeVersion (nodeRange) {
assert(/^node/.test(nodeRange));
return 'v' + nodeRange.slice(4);
}
for (const platform of knownPlatforms) {
const nodeRanges = [ 'node8', 'node10', 'node12' ];
if (platform === 'linux' || platform === 'alpine') nodeRanges.unshift('node6');
if (platform === 'linux') nodeRanges.unshift('node4');
for (const nodeRange of nodeRanges) {
const nodeVersion = nodeRangeToNodeVersion(nodeRange);
const archs = [ 'x64' ];
if (platform === 'win') archs.unshift('x86');