How to use the electron-rebuild.shouldRebuildNativeModules function in electron-rebuild

To help you get started, we’ve selected a few electron-rebuild 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 chrisenytc / ubauth / tasks / rebuild_native_modules.js View on Github external
// Rebuilds native node modules for Electron.
// More: https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md

'use strict';

var path = require('path');
var electron = require('electron-prebuilt');
var electronPackage = require('electron-prebuilt/package.json');
var rebuild = require('electron-rebuild');

var pathToElectronNativeModules = path.join(__dirname, '../app/node_modules');

rebuild.shouldRebuildNativeModules(electron)
.then(function (shouldBuild) {
    if (!shouldBuild) {
        return true;
    }

    console.log('Rebuilding native modules for Electron...'); // eslint-disable-line no-console

    return rebuild.installNodeHeaders(electronPackage.version)
    .then(function () {
        return rebuild.rebuildNativeModules(electronPackage.version, pathToElectronNativeModules);
    });
})
.then(function () {
    console.log('Rebuilding complete.'); // eslint-disable-line no-console
})
.catch(function (err) {
github ubergrape / grape-electron / tasks / rebuild_native_modules.js View on Github external
// Rebuilds native node modules for Electron.
// More: https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md

const path = require('path')
const Q = require('q')
const electron = require('electron')
const electronPackage = require('electron/package.json')
const rebuild = require('electron-rebuild')

const pathToElectronNativeModules = path.join(__dirname, '../app/node_modules')

rebuild
  .shouldRebuildNativeModules(electron)
  .then(shouldBuild => {
    if (!shouldBuild) {
      return true
    }

    console.log('Rebuilding native modules for Electron...')

    return rebuild
      .installNodeHeaders(electronPackage.version)
      .then(() =>
        rebuild.rebuildNativeModules(
          electronPackage.version,
          pathToElectronNativeModules,
        ),
      )
github paulsutherland / Polyonic / tasks / rebuild_native_modules.js View on Github external
// Rebuilds native node modules for Electron.
// More: https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md

'use strict'

const path = require('path')
const electron = require('electron')
const electronPackage = require('electron/package.json')
const rebuild = require('electron-rebuild')

let pathToElectronNativeModules = path.join(__dirname, '../build/node_modules')

rebuild.shouldRebuildNativeModules(electron)
.then(function (shouldBuild) {
  if (!shouldBuild) {
    return true
  }

  console.log('Rebuilding native modules for Electron...')

  return rebuild.installNodeHeaders(electronPackage.version)
    .then(function () {
      return rebuild.rebuildNativeModules(electronPackage.version, pathToElectronNativeModules)
    })
})
.then(function () {
  console.log('Rebuilding complete.')
})
.catch(function (err) {
github beakerbrowser / beaker / tasks / rebuild_native_modules.js View on Github external
// Rebuilds native node modules for Electron.
// More: https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md

'use strict';

var path = require('path');
var Q = require('q');
var electron = require('electron-prebuilt');
var electronPackage = require('electron-prebuilt/package.json');
var rebuild = require('electron-rebuild');

var pathToElectronNativeModules = path.join(__dirname, '../app/node_modules');

rebuild.shouldRebuildNativeModules(electron)
.then(function (shouldBuild) {
  if (!shouldBuild) {
    return true;
  }

  console.log('Rebuilding native modules for Electron...');

  return rebuild.installNodeHeaders(electronPackage.version)
  .then(function () {
    return rebuild.rebuildNativeModules(electronPackage.version, pathToElectronNativeModules);
  });
})
.then(function () {
  console.log('Rebuilding complete.');
})
.catch(function (err) {
github microsoft / pxt / electron / dev_tools / rebuildNative.js View on Github external
fs.readdirSync(p).forEach((item) => {
        let fullDependencyPath = path.join(p, item);
        let nodeModulesPath = path.join(fullDependencyPath, "node_modules");

        if (fs.statSync(fullDependencyPath).isDirectory() && fs.existsSync(nodeModulesPath)) {
            recurseFolders.push(nodeModulesPath);
        }
    });

    recurseFolders.forEach((f) => {
        cleanKnownModulesRecursive(f);
    });
}

electronRebuild.shouldRebuildNativeModules(electron)
    .then((shouldBuild) => {
        if (!shouldBuild) {
            console.log("It doesn't look like you need to rebuild");
            return Promise.resolve();
        }

        console.log("Detecting linked modules (\"npm link\")...");
        fs.readdirSync(targetDir).forEach((m) => {
            let moduleRootPath = path.resolve(targetDir, m);
            let stat = fs.statSync(moduleRootPath);

            if (stat.isDirectory()) {
                let finalLink = path.resolve(findFinalLinkTarget(moduleRootPath));

                if (finalLink !== moduleRootPath) {
                    console.log(`    Detected npm link: ${m}`);

electron-rebuild

Electron supporting package to rebuild native node modules against the currently installed electron

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis