Skip to content

Commit f334694

Browse files
author
Christopher Willis-Ford
committed
add 'npm run watch-gui', similar to build-gui
1 parent 723e701 commit f334694

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ that repository's main development line. For now, though, there's a separate bra
2323

2424
If you have run `npm link scratch-gui` (or equivalent) in the `scratch-desktop` working directory, you may be able to
2525
accomplish the above by running `npm run build-gui` in the `scratch-desktop` directory instead of using the manual
26-
steps listed above.
26+
steps listed above. For active development iteration, try `npm run watch-gui` which will watch for changes and rebuild
27+
`scratch-gui` incrementally when necessary.
2728

2829
### Prepare media library assets
2930

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"license": "BSD-3-Clause",
88
"scripts": {
99
"start": "electron-webpack dev --bail --display-error-details --env.minify=false",
10-
"build-gui": "node ./scripts/build-gui.js",
10+
"build-gui": "node ./scripts/run-in-gui.js build",
11+
"watch-gui": "node ./scripts/run-in-gui.js watch",
1112
"clean": "rimraf ./dist/ ./static/assets/",
1213
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
1314
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",

scripts/build-gui.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

scripts/run-in-gui.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const childProcess = require('child_process');
2+
const path = require('path');
3+
4+
// process.argv: ['node', 'run-in-gui.js', 'foo', ...]
5+
const args = process.argv.slice(2);
6+
args.unshift('run');
7+
// args: ['run', 'foo', ...]
8+
9+
// copy environment (including PATH) then add or replace BUILD_MODE and STATIC_PATH
10+
const env = {
11+
...process.env,
12+
BUILD_MODE: 'dist',
13+
STATIC_PATH: 'static'
14+
};
15+
16+
const child = childProcess.spawnSync(
17+
'npm', args,
18+
{
19+
cwd: path.join('node_modules', 'scratch-gui'),
20+
env,
21+
shell: true,
22+
stdio: 'inherit'
23+
}
24+
);
25+
26+
if (child.error) throw child.error;
27+
process.exit(child.status);

0 commit comments

Comments
 (0)