How to use node-pre-gyp - 10 common examples

To help you get started, we’ve selected a few node-pre-gyp 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 allenluce / mmap-object / test / util-interprocess.js View on Github external
'use strict'
/* global describe it before */
/*
  This utility file is intended to run in a different process space
  than the main tests.  This helps to ensure that things do get
  written to disk properly.  Doing these tests in the same process
  space where the tests are written is problematic as Boost shares
  allocators.
*/

const binary = require('node-pre-gyp')
const path = require('path')
const mmap_obj_path = binary.find(path.resolve(path.join(__dirname, '../package.json')))
const MmapObject = require(mmap_obj_path)
const expect = require('chai').expect

const BigKeySize = 1000
const BiggerKeySize = 10000

describe('Interprocess', function () {
  before(function () {
    this.reader = new MmapObject.Open(process.env.TESTFILE)
  })
  it('reads a string', function () {
    expect(this.reader.first).to.equal('value for first')
  })

  it('reads a string that was written twice', function () {
    expect(this.reader.samekey).to.equal('first value and a new value too')
github mapnik / node-mapnik / lib / mapnik.js View on Github external
}
    }
    return false;
}


var package_json = require('../package.json');
if (only_one(package_json)) {
    return;
}


var binary = require('node-pre-gyp');
var exists = require('fs').existsSync || require('path').existsSync;
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));
var settings_path = path.join(path.dirname(binding_path),'mapnik_settings.js');
var settings = require(settings_path);

var separator = (process.platform === 'win32') ? ';' : ':';

// set custom env settings before loading mapnik
if (settings.env) {
    var process_keys = Object.keys(process.env);
    for (var key in settings.env) {
        if (process_keys.indexOf(key) == -1) {
            process.env[key] = settings.env[key];
        } else {
            if (key === 'PATH') {
                process.env[key] = settings.env[key] + separator + process.env[key];
            }
        }
github mapnik / node-mapnik / bin / mapnik-index.js View on Github external
#!/usr/bin/env node

'use strict';

var binary = require('node-pre-gyp'),
    path = require('path'),
    bindingPath = binary.find(path.resolve(__dirname, '..', 'package.json')),
    program = path.join(path.dirname(bindingPath), 'bin', 'mapnik-index'),
    spawn = require('child_process').spawn,
    fs = require('fs');

if (!fs.existsSync(program)) {
  // assume it is not packaged but still on PATH
  program = 'mapnik-index';
}

var proc = spawn(program, process.argv.slice(2))
      .on('error', function(err) {
        if (err && err.code == 'ENOENT') {
          throw new Error("mapnik-index not found at " + program);
        }
        throw err;
      })
github enlight / electron-inspector / src / index.ts View on Github external
function isInspectorCompatible(electronVersion: string): boolean {
  // require.resolve() will throw if it fails to find the module
  let packageDir = path.dirname(
    require.resolve(path.join(__dirname, '../node_modules/v8-profiler'))
  );
  let binaryFile = findNativeModule(
    path.join(packageDir, 'package.json'),
    { runtime: 'electron', target: electronVersion }
  );
  if (!fs.existsSync(binaryFile)) {
    return false;
  }
  
  packageDir = path.dirname(require.resolve(path.join(__dirname, '../node_modules/v8-debug')));
  binaryFile = findNativeModule(
    path.join(packageDir, 'package.json'),
    { runtime: 'electron', target: electronVersion }
  );
  return fs.existsSync(binaryFile);
}
github OpenWebCAD / node-occ / lib / bindings.js View on Github external
const binary = require("node-pre-gyp");
const path = require("path");
const bindingPath = binary.find(path.resolve(path.join(__dirname, "../package.json")));
const binding = require(bindingPath);
module.exports = binding;// was require("../build/Release/occ");
//xx module.exports = require("../build/Debug/occ");
github zeit / pkg / test / test-79-npm / node-pre-gyp / node-pre-gyp.js View on Github external
'use strict';

var fs = require('fs');
if (!fs.existsSync('package.json')) {
  fs.writeFileSync('package.json', '{}');
}

var Run = require('node-pre-gyp').Run;
var r = new Run();

try {
  r.commands.clean();
} catch (e) {
  if (e.message.indexOf('undefined package.json is not node-pre-gyp ready') >= 0) {
    console.log('ok');
  }
}
github hansonw / fuzzy-native / tools / prepublish.js View on Github external
(function next(err) {
  if (err) {
    console.log(err.message);
    process.exit(1);
  }
  var target = targets.pop();
  if (!target) process.exit(0);
  var prog = new gyp.Run();
  prog.opts = target;
  prog.commands.install([], next);
})();
github node-inspector / v8-profiler / tools / prepublish-to-npm.js View on Github external
module.exports = function prepublish(err) {
  if (err) {
    console.log(err.message);
    return process.exit(1);
  }

  var target = targets.pop();

  if (!target) process.exit(0);

  var prog = extend(new gyp.Run(), {opts: target});

  prog.commands.install([], prepublish);
};
github Kitt-AI / snowboy / lib / node / index.ts View on Github external
import * as stream from 'stream';
import * as path from 'path';
import * as fs from 'fs';
import * as binary from 'node-pre-gyp';

const bindingPath: string = binary.find(path.resolve(path.join(__dirname, '../../package.json')));
const SnowboyDetectNative: SnowboyDetectNativeInterface = require(bindingPath).SnowboyDetect;

enum DetectionResult {
  SILENCE = -2,
  ERROR = -1,
  SOUND = 0
}

enum ModelType {
  PMDL,
  UMDL
}

export interface HotwordModel {
  file: string;
  sensitivity?: string;
github JCMais / node-libcurl / lib / Multi.js View on Github external
/**
 * Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const path = require('path')

const binary = require('node-pre-gyp')

const bindingPath = binary.find(
  path.resolve(path.join(__dirname, './../package.json')),
)

/**
 * Multi handle constructor
 *
 * @constructor
 * @alias module:node-libcurl.Multi
 */
const Multi = (module.exports = require(bindingPath).Multi)

/**
 * Use {@link module:node-libcurl.Curl.multi} for predefined constants.
 *
 * Official libcurl documentation: [curl_multi_setopt()]{@link http://curl.haxx.se/libcurl/c/curl_multi_setopt.html}
 *

node-pre-gyp

Node.js native addon binary install tool

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

58 / 100
Full package analysis