How to use the getRoot function from bindings

Find comprehensive JavaScript bindings.getRoot code examples handpicked from public code repositorys.

198
199
200
201
202
203
204
205
206
207
// heuristics for detecting common dynamically imported native modules
// important for generating a working config for apps with native modules
if (importMap.bindings) {
  // detect native modules using "bindings" package
  try {
    const packageDir = bindings.getRoot(filename)
    const nativeModulePath = bindings({ path: true, module_root: packageDir })
    importMap[nativeModulePath] = nativeModulePath
  } catch (err) {
    // ignore resolution failures
fork icon52
star icon628
watch icon19

+ 3 other calls in file

119
120
121
122
123
124
125
126
127
128
// Find all modules that include a compiled binary
var patterns = ['node_modules/**/*.node', 'node_modules/**/binding.gyp'];
var binaries = glob.files(globRoot, patterns).reduce((bins, globPath) => {
  // Gather information about each found module
  var resolved = true;
  var modulePath = bindings.getRoot(globPath);
  var packageJson = require(path.join(globRoot, modulePath, 'package.json'));
  var binName = path.basename(globPath);
  var buildPath = path.normalize(globPath.replace(path.join(modulePath), '').replace(binName, ''));
  var buildType = (function() {
fork icon56
star icon115
watch icon0

2
3
4
5
6
7
8
9
10
11
12
var exec = require('child_process').exec;
var bindings = require('bindings');
var index = require('../');
var log = index.log;


var packageRoot = bindings.getRoot(bindings.getFileName());
var binaryPath = bindings({
  path: true,
  bindings: 'bitcoind.node'
});
fork icon0
star icon0
watch icon0

Other functions in bindings

Sorted by popularity

function icon

bindings.createKey is the most popular function in bindings (8616 examples)