describe(`toJson`, () => { const v = process.versions.node.split(`.`), highVer = +v[0], lowVer = +v[1]; if (highVer > 10 || (highVer === 10 && lowVer >= 4)) { // Node.js v10.4.0 is required to support BigInt natively. describe(`for a direct value`, () => { expect(internal.toJson(BigInt(`0`))).toBe(`0`); expect(internal.toJson(BigInt(`123`))).toBe(`123`); expect(internal.toJson(BigInt(`-12345678901234567890`))).toBe(`-12345678901234567890`); }); describe(`for an object`, () => { expect(internal.toJson({value: BigInt(`0`)})).toEqual(`{"value":0}`); expect(internal.toJson({value: BigInt(`123`)})).toEqual(`{"value":123}`); expect(internal.toJson({value: BigInt(`-456`)})).toEqual(`{"value":-456}`); const mix1 = { val1: 12345678901234567890, val2: BigInt(`12345678901234567890`) }; expect(internal.toJson(mix1)).toEqual(`{"val1":12345678901234567000,"val2":12345678901234567890}`); }); describe(`for an undefined`, () => { expect(internal.toJson()).toBeUndefined(); expect(internal.toJson(undefined)).toBeUndefined(); }); } });
static onCheckParams({ method = DEFAULT_METHOD }) { const cipherNames = Object.keys(ciphers); if (!cipherNames.includes(method)) { throw Error(`"method" must be one of ${cipherNames}, but got "${method}"`); } if (method.endsWith('ccm') && !_semver.default.gte(process.versions.node, '10.2.0')) { throw Error('CCM mode requires Node.js >= v10.2.0'); } }
function printPlatform() { const sysInfo = (...keys) => keys.map(key => os[key]()).join(' / '); const cpuInfo = () => [os.cpus()[0].model, os.cpus().length].join(' × '); const infoTable = new Table(); infoTable.cell('os', sysInfo('type', 'release', 'arch')); infoTable.cell('cpu', cpuInfo()); infoTable.cell('node', process.versions.node + ' / v8: ' + process.versions.v8); infoTable.newRow(); console.log(infoTable.printTransposed({ separator: ' : ', namePrinter: Table.leftPadder(' ') })); }
[ '', ' Usage: node-gyp <command> [options]', '', ' where <command> is one of:', commands.map(function (c) { return ' - ' + c + ' - ' + require('./' + c).usage }).join('\n'), '', 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..'), 'node@' + process.versions.node ].join('\n')
// eslint-disable-line node/prefer-global/process function getClosestVersion() { if (!process.versions.v8) { // Assume compatibility with Node.js 8.9.4 return 'v8-6.1'; } const v8 = parseFloat(process.versions.v8); if (v8 >= 6.6) { return 'v8-6.6'; } if (v8 >= 6.2) { return 'v8-6.2'; } return 'v8-6.1'; }
test('async await support', t => { if (Number(process.versions.node[0]) >= 8) { require('./async-await')(t.test, port) } else { t.pass('Skip because Node version < 8') } t.end() })
test('examples/three-lines.js', (t) => { const script = Path.join('examples', 'three-lines.js'); const cli = startCLI([script]); return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { t.match(cli.output, 'debug>', 'prints a prompt'); t.match( cli.output, /< Debugger listening on [^\n]*9229/, 'forwards child output'); }) .then(() => cli.command('["hello", "world"].join(" ")')) .then(() => { t.match(cli.output, 'hello world', 'prints the result'); }) .then(() => cli.command('')) .then(() => { t.match(cli.output, 'hello world', 'repeats the last command on <enter>'); }) .then(() => cli.command('version')) .then(() => { t.match(cli.output, process.versions.v8, 'version prints the v8 version'); }) .then(() => cli.quit()) .then((code) => { t.equal(code, 0, 'exits with success'); }); });
static onCheckParams({ method = DEFAULT_METHOD }) { const cipherNames = Object.keys(ciphers); if (!cipherNames.includes(method)) { throw Error(`"method" must be one of ${cipherNames}, but got "${method}"`); } if (method.endsWith('ccm') && !semver.gte(process.versions.node, '10.2.0')) { throw Error('CCM mode requires Node.js >= v10.2.0'); } }
function printPlatform() { const sysInfo = (...keys) => keys.map(key => os[key]()).join(' / '); const cpuInfo = () => [os.cpus()[0].model, os.cpus().length].join(' × '); const infoTable = new Table(); infoTable.cell('os', sysInfo('type', 'release', 'arch')); infoTable.cell('cpu', cpuInfo()); infoTable.cell('node', process.versions.node + ' / v8: ' + process.versions.v8); infoTable.newRow(); console.log(infoTable.printTransposed({ separator: ' : ', namePrinter: Table.leftPadder(' ') })); }