4 * Provides the build:js command to compile *.es6.js files to ES5.
6 * Run build:js with --file to only parse a specific file. Using the --check
7 * flag build:js can be run to check if files are compiled correctly.
8 * @example <caption>Only process misc/drupal.es6.js and misc/drupal.init.es6.js</caption
9 * yarn run build:js -- --file misc/drupal.es6.js --file misc/drupal.init.es6.js
10 * @example <caption>Check if all files have been compiled correctly</caption
11 * yarn run build:js -- --check
13 * @internal This file is part of the core javascript build process and is only
14 * meant to be used in that context.
19 const glob = require('glob');
20 const argv = require('minimist')(process.argv.slice(2));
21 const changeOrAdded = require('./changeOrAdded');
22 const check = require('./check');
23 const log = require('./log');
25 // Match only on .es6.js files.
26 const fileMatch = './**/*.es6.js';
27 // Ignore everything in node_modules
29 ignore: './node_modules/**'
31 const processFiles = (error, filePaths) => {
35 // Process all the found files.
36 let callback = changeOrAdded;
40 filePaths.forEach(callback);
44 processFiles(null, [].concat(argv.file));
47 glob(fileMatch, globOptions, processFiles);