diff --git a/src/util/rebuild.js b/src/util/rebuild.js index 8fbf4712d3..0471177a5f 100644 --- a/src/util/rebuild.js +++ b/src/util/rebuild.js @@ -79,13 +79,14 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => { } }; - const rebuildAllModulesIn = (nodeModulesPath) => { + const rebuildAllModulesIn = (nodeModulesPath, prefix = '') => { + d('scanning:', nodeModulesPath); for (const modulePath of fs.readdirSync(nodeModulesPath)) { - if (prodDeps[modulePath]) { + if (prodDeps[`${prefix}${modulePath}`]) { rebuilds.push(rebuildModuleAt(path.resolve(nodeModulesPath, modulePath))); } - if (path.resolve(nodeModulesPath, modulePath).startsWith('@')) { - rebuildAllModulesIn(path.resolve(nodeModulesPath, modulePath)); + if (modulePath.startsWith('@')) { + rebuildAllModulesIn(path.resolve(nodeModulesPath, modulePath), `${modulePath}/`); } if (fs.existsSync(path.resolve(nodeModulesPath, modulePath, 'node_modules'))) { rebuildAllModulesIn(path.resolve(nodeModulesPath, modulePath, 'node_modules')); @@ -107,6 +108,7 @@ export default async (buildPath, electronVersion, pPlatform, pArch) => { }; const markChildrenAsProdDeps = async (modulePath) => { + d('exporing:', modulePath); const childPackageJSON = JSON.parse(await fs.readFile(path.resolve(modulePath, 'package.json'), 'utf8')); const moduleWait = []; Object.keys(childPackageJSON.dependencies || {}).forEach((key) => { diff --git a/test/fixture/native_app/package.json b/test/fixture/native_app/package.json index 8790368dbf..9e2ce37b8c 100644 --- a/test/fixture/native_app/package.json +++ b/test/fixture/native_app/package.json @@ -18,10 +18,10 @@ }, "dependencies": { "ref": "1.3.3", - "node-mdns-easy": "1.0.4", - "@onehilltech/gatekeeper": "0.46.1" + "benchr": "3.2.0", + "@newrelic/native-metrics": "1.0.0" }, "optionalDependencies": { - "utp-native": "1.3.2" + "zipfile": "0.5.11" } } diff --git a/test/rebuild_spec.js b/test/rebuild_spec.js index 89e0618549..882948b1e7 100644 --- a/test/rebuild_spec.js +++ b/test/rebuild_spec.js @@ -1,10 +1,7 @@ import fs from 'fs-promise'; -import mkdirp from 'mkdirp'; import path from 'path'; -import pify from 'pify'; import os from 'os'; import ora from 'ora'; -import rimraf from 'rimraf'; import { spawn as yarnOrNPMSpawn, hasYarn } from 'yarn-or-npm'; import { expect } from 'chai'; @@ -17,14 +14,13 @@ describe('rebuilder', () => { const testModulePath = path.resolve(os.tmpdir(), 'electron-forge-rebuild-test'); before(async () => { - await pify(rimraf)(testModulePath); - console.log(testModulePath); - await pify(mkdirp)(testModulePath); + await fs.remove(testModulePath); + await fs.mkdirs(testModulePath); await fs.writeFile(path.resolve(testModulePath, 'package.json'), await fs.readFile(path.resolve(__dirname, 'fixture/native_app/package.json'), 'utf8')); await new Promise((resolve, reject) => { const child = yarnOrNPMSpawn(hasYarn() ? [] : ['install'], { cwd: testModulePath, - stdio: 'inherit', + stdio: process.platform === 'win32' ? 'inherit' : 'pipe', }); child.on('exit', (code) => { if (code === 0) resolve(); @@ -43,18 +39,18 @@ describe('rebuilder', () => { }); it('should have rebuilt children of top level prod dependencies', async () => { - const forgeMeta = path.resolve(testModulePath, 'node_modules', 'mdns', 'build', 'Release', '.forge-meta'); - expect(await fs.exists(forgeMeta), 'mdns build meta should exist').to.equal(true); + const forgeMeta = path.resolve(testModulePath, 'node_modules', 'microtime', 'build', 'Release', '.forge-meta'); + expect(await fs.exists(forgeMeta), 'microtime build meta should exist').to.equal(true); }); it('should have rebuilt children of scoped top level prod dependencies', async () => { - const forgeMeta = path.resolve(testModulePath, 'node_modules', 'bcrypt', 'build', 'Release', '.forge-meta'); - expect(await fs.exists(forgeMeta), 'bcrypt build meta should exist').to.equal(true); + const forgeMeta = path.resolve(testModulePath, 'node_modules', '@newrelic/native-metrics', 'build', 'Release', '.forge-meta'); + expect(await fs.exists(forgeMeta), '@newrelic/native-metrics build meta should exist').to.equal(true); }); it('should have rebuilt top level optional dependencies', async () => { - const forgeMeta = path.resolve(testModulePath, 'node_modules', 'utp-native', 'build', 'Release', '.forge-meta'); - expect(await fs.exists(forgeMeta), 'utp-native build meta should exist').to.equal(true); + const forgeMeta = path.resolve(testModulePath, 'node_modules', 'zipfile', 'build', 'Release', '.forge-meta'); + expect(await fs.exists(forgeMeta), 'zipfile build meta should exist').to.equal(true); }); it('should not have rebuilt top level devDependencies', async () => { @@ -63,6 +59,6 @@ describe('rebuilder', () => { }); after(async () => { - await pify(rimraf)(testModulePath); + await fs.remove(testModulePath); }); });