mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
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
This commit is contained in:
@@ -48,7 +48,7 @@
|
|||||||
"publish:beta": "npm ci && gulp publishBeta",
|
"publish:beta": "npm ci && gulp publishBeta",
|
||||||
"recompile": "gulp recompile",
|
"recompile": "gulp recompile",
|
||||||
"release": "gulp gitCreateRC",
|
"release": "gulp gitCreateRC",
|
||||||
"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\"",
|
"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\"",
|
||||||
"tsc": "gulp tsc",
|
"tsc": "gulp tsc",
|
||||||
"test": "gulp test",
|
"test": "gulp test",
|
||||||
"test:browser": "cd tests/browser && npx mocha",
|
"test:browser": "cd tests/browser && npx mocha",
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ const {posixPath} = require('../helpers');
|
|||||||
// Build //
|
// Build //
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the python runtime.
|
||||||
|
* This will normalize the command across platforms (e.g. python3 on Linux and
|
||||||
|
* Mac, python on Windows).
|
||||||
|
*/
|
||||||
|
const PYTHON = process.platform === 'win32' ? 'python' : 'python3';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suffix to add to compiled output files.
|
* Suffix to add to compiled output files.
|
||||||
*/
|
*/
|
||||||
@@ -380,7 +387,7 @@ error message above, try running:
|
|||||||
*/
|
*/
|
||||||
function generateMessages(done) {
|
function generateMessages(done) {
|
||||||
// Run js_to_json.py
|
// Run js_to_json.py
|
||||||
const jsToJsonCmd = `python3 scripts/i18n/js_to_json.py \
|
const jsToJsonCmd = `${PYTHON} scripts/i18n/js_to_json.py \
|
||||||
--input_file ${path.join('msg', 'messages.js')} \
|
--input_file ${path.join('msg', 'messages.js')} \
|
||||||
--output_dir ${path.join('msg', 'json')} \
|
--output_dir ${path.join('msg', 'json')} \
|
||||||
--quiet`;
|
--quiet`;
|
||||||
@@ -418,7 +425,8 @@ function buildLangfiles(done) {
|
|||||||
json_files = json_files.filter(file => file.endsWith('json') &&
|
json_files = json_files.filter(file => file.endsWith('json') &&
|
||||||
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
|
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
|
||||||
json_files = json_files.map(file => path.join('msg', 'json', file));
|
json_files = json_files.map(file => path.join('msg', 'json', file));
|
||||||
const createMessagesCmd = `python3 ./scripts/i18n/create_messages.py \
|
|
||||||
|
const createMessagesCmd = `${PYTHON} ./scripts/i18n/create_messages.py \
|
||||||
--source_lang_file ${path.join('msg', 'json', 'en.json')} \
|
--source_lang_file ${path.join('msg', 'json', 'en.json')} \
|
||||||
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
|
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
|
||||||
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
|
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
|
||||||
@@ -559,7 +567,10 @@ function getChunkOptions() {
|
|||||||
// Figure out which chunk this is by looking for one of the
|
// Figure out which chunk this is by looking for one of the
|
||||||
// known chunk entrypoints in chunkFiles. N.B.: O(n*m). :-(
|
// known chunk entrypoints in chunkFiles. N.B.: O(n*m). :-(
|
||||||
const chunk = chunks.find(
|
const chunk = chunks.find(
|
||||||
chunk => chunkFiles.find(f => f.endsWith(path.sep + chunk.entry)));
|
chunk => chunkFiles.find(f => {
|
||||||
|
return f.endsWith('/' + chunk.entry.replaceAll('\\', '/'));
|
||||||
|
}
|
||||||
|
));
|
||||||
if (!chunk) throw new Error('Unable to identify chunk');
|
if (!chunk) throw new Error('Unable to identify chunk');
|
||||||
|
|
||||||
// Replace nicknames with the names we chose.
|
// Replace nicknames with the names we chose.
|
||||||
|
|||||||
Reference in New Issue
Block a user