Build msg/js/*.js langfiles in BUILD_DIR

This commit is contained in:
Christopher Allen
2021-06-22 12:04:30 +01:00
parent a03cd29b68
commit 25f073d0e3
2 changed files with 10 additions and 5 deletions

View File

@@ -443,7 +443,12 @@ this removal!
* msg/*.js
*/
function buildLangfiles(done) {
// Run create_messages.py
// Create output directory.
// BUG(cpcallen): this probably doesn't work on Windows.
const outputDir = path.join(BUILD_DIR, 'msg', 'js');
execSync(`mkdir -p ${outputDir}`, {stdio: 'inherit'});
// Run create_messages.py.
let json_files = fs.readdirSync(path.join('msg', 'json'));
json_files = json_files.filter(file => file.endsWith('json') &&
!(new RegExp(/(keys|synonyms|qqq|constants)\.json$/).test(file)));
@@ -453,9 +458,9 @@ function buildLangfiles(done) {
--source_synonym_file ${path.join('msg', 'json', 'synonyms.json')} \
--source_constants_file ${path.join('msg', 'json', 'constants.json')} \
--key_file ${path.join('msg', 'json', 'keys.json')} \
--output_dir ${path.join('msg', 'js')} \
--output_dir ${outputDir} \
--quiet ${json_files.join(' ')}`;
execSync(createMessagesCmd, { stdio: 'inherit' });
execSync(createMessagesCmd, {stdio: 'inherit'});
done();
};

View File

@@ -287,12 +287,12 @@ function packagePHP() {
};
/**
* This task wraps each of the msg/js/* files into a UMD module.
* This task wraps each of the ${BUILD_DIR}/msg/js/* files into a UMD module.
* @example import * as En from 'blockly/msg/en';
*/
function packageLocales() {
// Remove references to goog.provide and goog.require.
return gulp.src('msg/js/*.js')
return gulp.src(`${BUILD_DIR}/msg/js/*.js`)
.pipe(gulp.replace(/goog\.[^\n]+/g, ''))
.pipe(gulp.insert.prepend(`
var Blockly = {};Blockly.Msg={};`))