Skip to content

Commit 5e0390b

Browse files
fix(build): support running Blocky locally on Windows machines (#7281)
* fix: update build path for windows When using single quote on windows, e.g. 'build/src', the folder are created with a single quote at the beginning `'build` and end `src'`. This commit fixes this issue. * fix: update python command and folder separator Ensure that when running on windows, python command is python and not python3. Also, separators are normalized to posix style `/` even on windows system * fix: add global PYTHON constant to run python command * fix: simplify `path.sep` to forwadslash since it is cross-platform * fix(syntax): replace double quote with single quote
1 parent f3899e2 commit 5e0390b

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"publish:beta": "npm ci && gulp publishBeta",
4949
"recompile": "gulp recompile",
5050
"release": "gulp gitCreateRC",
51-
"start": "npm run build && concurrently -n tsc,server \"tsc --watch --preserveWatchOutput --outDir 'build/src' --declarationDir 'build/declarations'\" \"http-server ./ -s -o /tests/playground.html -c-1\"",
51+
"start": "npm run build && concurrently -n tsc,server \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"http-server ./ -s -o /tests/playground.html -c-1\"",
5252
"tsc": "gulp tsc",
5353
"test": "gulp test",
5454
"test:browser": "cd tests/browser && npx mocha",

scripts/gulpfiles/build_tasks.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const {posixPath} = require('../helpers');
3030
// Build //
3131
////////////////////////////////////////////////////////////
3232

33+
/**
34+
* Path to the python runtime.
35+
* This will normalize the command across platforms (e.g. python3 on Linux and
36+
* Mac, python on Windows).
37+
*/
38+
const PYTHON = process.platform === 'win32' ? 'python' : 'python3';
39+
3340
/**
3441
* Suffix to add to compiled output files.
3542
*/
@@ -380,7 +387,7 @@ error message above, try running:
380387
*/
381388
function generateMessages(done) {
382389
// Run js_to_json.py
383-
const jsToJsonCmd = `python3 scripts/i18n/js_to_json.py \
390+
const jsToJsonCmd = `${PYTHON} scripts/i18n/js_to_json.py \
384391
--input_file ${path.join('msg', 'messages.js')} \
385392
--output_dir ${path.join('msg', 'json')} \
386393
--quiet`;
@@ -418,7 +425,8 @@ function buildLangfiles(done) {
418425
json_files = json_files.filter(file => file.endsWith('json') &&
419426
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
420427
json_files = json_files.map(file => path.join('msg', 'json', file));
421-
const createMessagesCmd = `python3 ./scripts/i18n/create_messages.py \
428+
429+
const createMessagesCmd = `${PYTHON} ./scripts/i18n/create_messages.py \
422430
--source_lang_file ${path.join('msg', 'json', 'en.json')} \
423431
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
424432
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
@@ -559,7 +567,10 @@ function getChunkOptions() {
559567
// Figure out which chunk this is by looking for one of the
560568
// known chunk entrypoints in chunkFiles. N.B.: O(n*m). :-(
561569
const chunk = chunks.find(
562-
chunk => chunkFiles.find(f => f.endsWith(path.sep + chunk.entry)));
570+
chunk => chunkFiles.find(f => {
571+
return f.endsWith('/' + chunk.entry.replaceAll('\\', '/'));
572+
}
573+
));
563574
if (!chunk) throw new Error('Unable to identify chunk');
564575

565576
// Replace nicknames with the names we chose.

0 commit comments

Comments
 (0)