Skip to content

Commit

Permalink
Fixed postinstall script for windows (#1367)
Browse files Browse the repository at this point in the history
* Initial cross platform postinstall script fix

* Fixed cwd for postinstall script

* Attempt fix for cross-platform test path

* Cleaned up RunScripts
  • Loading branch information
amilajack authored Jan 8, 2018
1 parent 177b3a3 commit d81d0be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/chentsulin"
},
"scripts": {
"electron-rebuild": "../node_modules/.bin/electron-rebuild --parallel --force --types prod,dev,optional --module-dir .",
"electron-rebuild": "node -r babel-register ../internals/scripts/ElectronRebuild.js",
"postinstall": "npm run electron-rebuild"
},
"license": "MIT",
Expand Down
14 changes: 14 additions & 0 deletions internals/scripts/ElectronRebuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @flow
import path from 'path';
import { execSync } from 'child_process';

const electronRebuildCmd =
'../node_modules/.bin/electron-rebuild --parallel --force --types prod,dev,optional --module-dir .';

const cmd = process.platform === 'win32'
? electronRebuildCmd.replace(/\//g, '\\')
: electronRebuildCmd;

execSync(cmd, {
cwd: path.join(__dirname, '..', '..', 'app')
});
9 changes: 4 additions & 5 deletions test/runTests.js → internals/scripts/RunTests.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const spawn = require('cross-spawn');
const path = require('path');
import spawn from 'cross-spawn';
import path from 'path';

const s = `\\${path.sep}`;
const pattern = process.argv[2] === 'e2e'
? `test${s}e2e${s}.+\\.spec\\.js`
: `test${s}(?!e2e${s})[^${s}]+${s}.+\\.spec\\.js$`;
? 'test/e2e/.+\\.spec\\.js'
: 'test/(?!e2e/)[^/]+/.+\\.spec\\.js$';

const result = spawn.sync(
path.normalize('./node_modules/.bin/jest'),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"start": "cross-env NODE_ENV=production electron ./app/",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
"start-renderer-dev": "cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack.config.renderer.dev.js",
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js",
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings -r babel-register ./internals/scripts/RunTests.js",
"test-all": "npm run lint && npm run flow && npm run build && npm run test && npm run test-e2e",
"test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js e2e",
"test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings -r babel-register ./internals/scripts/RunTests.js e2e",
"test-watch": "npm test -- --watch"
},
"browserslist": "electron 1.6",
Expand Down

0 comments on commit d81d0be

Please sign in to comment.