How to use the detect-libc.isNonGlibcLinux function in detect-libc

To help you get started, we’ve selected a few detect-libc 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 lovell / sharp / lib / platform.js View on Github external
module.exports = function () {
  const arch = env.npm_config_arch || process.arch;
  const platform = env.npm_config_platform || process.platform;
  /* istanbul ignore next */
  const libc = (platform === 'linux' && detectLibc.isNonGlibcLinux) ? detectLibc.family : '';

  const platformId = [`${platform}${libc}`];

  if (arch === 'arm') {
    platformId.push(`armv${env.npm_config_arm_version || process.config.variables.arm_version || '6'}`);
  } else if (arch === 'arm64') {
    platformId.push(`arm64v${env.npm_config_arm_version || '8'}`);
  } else {
    platformId.push(arch);
  }

  return platformId.join('-');
};
github prebuild / prebuild-install / rc.js View on Github external
var minimist = require('minimist')
var getAbi = require('node-abi').getAbi
var detectLibc = require('detect-libc')
var napi = require('napi-build-utils')

var env = process.env

var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''

// Get `prebuild-install` arguments that were passed to the `npm` command
if (env.npm_config_argv) {
  var npmargs = ['prebuild', 'compile', 'build-from-source', 'debug', 'verbose']
  try {
    var npmArgv = JSON.parse(env.npm_config_argv).cooked
    for (var i = 0; i < npmargs.length; ++i) {
      if (npmArgv.indexOf('--' + npmargs[i]) !== -1) {
        process.argv.push('--' + npmargs[i])
      }
      if (npmArgv.indexOf('--no-' + npmargs[i]) !== -1) {
        process.argv.push('--no-' + npmargs[i])
      }
    }
    if ((i = npmArgv.indexOf('--download')) !== -1) {
      process.argv.push(npmArgv[i], npmArgv[i + 1])
github lovell / sharp / binding.js View on Github external
const currentPlatformId = platform();
  try {
    const vendorPlatformId = require(path.join(__dirname, 'vendor', 'platform.json'));
    if (currentPlatformId === vendorPlatformId) {
      return;
    } else {
      error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.`);
    }
  } catch (err) {}
  // Ensure Intel 64-bit or ARM
  const arch = process.env.npm_config_arch || process.arch;
  if (arch === 'ia32') {
    error(`Intel Architecture 32-bit systems require manual installation of libvips >= ${minimumLibvipsVersion} - please see http://sharp.pixelplumbing.com/page/install`);
  }
  // Ensure glibc Linux
  if (detectLibc.isNonGlibcLinux) {
    error(`Use with ${detectLibc.family} libc requires manual installation of libvips >= ${minimumLibvipsVersion} - please see http://sharp.pixelplumbing.com/page/install`);
  }
  // Ensure glibc >= 2.13
  if (detectLibc.family === detectLibc.GLIBC && detectLibc.version && semver.lt(`${detectLibc.version}.0`, '2.13.0')) {
    error(`Use with glibc version ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion} - please see http://sharp.pixelplumbing.com/page/install`);
  }
  // Arch/platform-specific .tar.gz
  const tarFilename = ['libvips', minimumLibvipsVersion, currentPlatformId].join('-') + '.tar.gz';
  // Download to per-process temporary file
  const tarPathTemp = path.join(os.tmpdir(), `${process.pid}-${tarFilename}`);
  const tmpFile = fs.createWriteStream(tarPathTemp).on('close', function () {
    unpack(tarPathTemp, function () {
      // Attempt to remove temporary file
      try {
        fs.unlinkSync(tarPathTemp);
      } catch (err) {}
github prebuild / prebuild / rc.js View on Github external
var minimist = require('minimist')
var targets = require('node-abi').supportedTargets
var detectLibc = require('detect-libc')
var napi = require('napi-build-utils')

var libc = process.env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''

var rc = require('rc')('prebuild', {
  target: process.versions.node,
  runtime: 'node',
  arch: process.arch,
  libc: libc,
  platform: process.platform,
  all: false,
  force: false,
  debug: false,
  verbose: false,
  path: '.',
  backend: 'node-gyp',
  format: false,
  'include-regex': '\\.node$',
  'tag-prefix': 'v'
github nstepien / iltorb / scripts / build.js View on Github external
function build({target, runtime, abi}) {
  try {
    abi && getTarget(target, runtime);
  } catch (err) {
    return Promise.resolve();
  }

  const args = ['--verbose', '-r', runtime, '-t', target];

  if (libc.isNonGlibcLinux) {
    process.env.LIBC = libc.family;
  }

  if (PUBLISH_BINARY) {
    args.push('-u', PREBUILD_TOKEN);
  }

  return new Promise((resolve, reject) => {
    const proc = spawn('prebuild', args, { env: npmRunPath.env() });

    proc.stdout.pipe(process.stdout);
    proc.stderr.pipe(process.stderr);
    proc.on('exit', (code) => {
      if (code) {
        return reject(code);
      }

detect-libc

Node.js module to detect the C standard library (libc) implementation family and version

Apache-2.0
Latest version published 8 months ago

Package Health Score

71 / 100
Full package analysis