From c39b82ae1ee3416ece888b30ce75ea5c0b89b033 Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Tue, 9 Jan 2018 15:37:28 -0800 Subject: [PATCH] Fix electron-rebuild script (#1370) * Fix electron-rebuild script * Added node_modules path existence check for rebuild script --- internals/scripts/ElectronRebuild.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/internals/scripts/ElectronRebuild.js b/internals/scripts/ElectronRebuild.js index b114ccb..b680da1 100644 --- a/internals/scripts/ElectronRebuild.js +++ b/internals/scripts/ElectronRebuild.js @@ -1,14 +1,21 @@ // @flow import path from 'path'; import { execSync } from 'child_process'; +import fs from 'fs'; +import dependencies from '../../app/package.json'; -const electronRebuildCmd = +const nodeModulesPath = + path.join(__dirname, '..', '..', 'app', 'node_modules'); + +if (Object.keys(dependencies || {}).length > 0 && fs.existsSync(nodeModulesPath)) { + const electronRebuildCmd = '../node_modules/.bin/electron-rebuild --parallel --force --types prod,dev,optional --module-dir .'; -const cmd = process.platform === 'win32' - ? electronRebuildCmd.replace(/\//g, '\\') - : electronRebuildCmd; + const cmd = process.platform === 'win32' + ? electronRebuildCmd.replace(/\//g, '\\') + : electronRebuildCmd; -execSync(cmd, { - cwd: path.join(__dirname, '..', '..', 'app') -}); + execSync(cmd, { + cwd: path.join(__dirname, '..', '..', 'app') + }); +}