Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
if (platform === 'linux') archs.push('armv7');
// linux-armv7 is needed in multi-arch tests,
// so keeping it here as obligatory. but let's
// leave compiling for freebsd to end users
if (platform === 'freebsd') continue;
for (const arch of archs) {
if (dontBuild(nodeVersion, platform, arch)) continue;
items.push({ nodeRange, platform, arch });
}
}
}
let p = Promise.resolve();
items.forEach((item) => {
p = p.then(() => fetch.need(item));
});
p.catch((error) => {
if (!error.wasReported) console.log(`> ${error}`);
process.exit(2);
});
'use strict';
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 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');
p = p.then(() => fetch.need(item));
});
constructor(platform, pathspec, opts) {
assert(opts && 'object' === typeof opts, '`opts` is not an object.')
assert('string' === typeof opts.output, '`opts.output` is not a string.')
const host = system.toFancyPlatform(opts.platform || platform.host)
const { type = DEFAULT_TYPE } = opts
assert('string' === typeof type, '`opts.type` is not a string.')
const basename = path.basename(pathspec)
const extname = path.extname(pathspec)
if (Array.isArray(opts.assets)) {
this.assets = opts.assets
.filter(Boolean)
.map((asset) => 'string' === typeof asset
? asset.split(':')
: asset)
.map((tuple) => Array.isArray(tuple) && 2 === tuple.length
? ({ from: tuple[0], to: tuple[1] })
: tuple)
async function needViaCache (target) {
const s = stringifyTarget(target);
let c = targetsCache[s];
if (c) return c;
c = await need(target);
targetsCache[s] = c;
return c;
}
async function needWithDryRun (target) {
const target2 = Object.assign({ dryRun: true }, target);
const result = await need(target2);
assert([ 'exists', 'fetched', 'built' ].indexOf(result) >= 0);
dryRunResults[result] = true;
}
const { Builder } = require('./builder')
const { system } = require('pkg-fetch')
const assert = require('assert')
const mkdirp = require('mkdirp')
const Batch = require('batch')
const debug = require('debug')('pkg-packager')
const path = require('path')
/**
* The host platform name in fancy form for `pkg`.
* @private
*/
const PKG_PLATFORM = system.toFancyPlatform(process.platform)
/**
* The default builder type based on `PKG_PLATFORM`.
* @private
*/
const DEFAULT_TYPE = ({
linux: 'appimage',
macos: 'appdmg',
win: 'exe',
})[PKG_PLATFORM]
/**
* The `Target` class represents a container for
* a packaging builder target. Builders are loaded based
* on platform information and target configuration.
* @public