From 25f073d0e37451cc009905d6ef2f9f52098924c3 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 22 Jun 2021 12:04:30 +0100 Subject: [PATCH] Build msg/js/*.js langfiles in BUILD_DIR --- scripts/gulpfiles/build_tasks.js | 11 ++++++++--- scripts/gulpfiles/package_tasks.js | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index f57e0d178..69fda0a23 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -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(); }; diff --git a/scripts/gulpfiles/package_tasks.js b/scripts/gulpfiles/package_tasks.js index f1dfd121a..84f79668c 100644 --- a/scripts/gulpfiles/package_tasks.js +++ b/scripts/gulpfiles/package_tasks.js @@ -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={};`))