How to use the pkg-fetch.system function in pkg-fetch

To help you get started, we’ve selected a few pkg-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / pkg / test / test-50-bakery-fetch / main.js View on Github external
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);
});
github zeit / pkg / test / test-50-bakery-fetch / main.js View on Github external
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);
});
github zeit / pkg / test / test-42-fetch-all / main.js View on Github external
#!/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');

pkg-fetch

Compiles and stores base binaries for pkg

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis