How to use the pkg-fetch.need 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
'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);
github zeit / pkg / lib / index.js View on Github external
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;
}
github zeit / pkg / lib / index.js View on Github external
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;
}

pkg-fetch

Compiles and stores base binaries for pkg

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis