2016-10-24 05:48:27 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Compile *.es6.js files to ES5.
|
|
|
|
*
|
|
|
|
* @internal This file is part of the core javascript build process and is only
|
|
|
|
* meant to be used in that context.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const glob = require('glob');
|
|
|
|
|
2017-05-10 15:19:59 +00:00
|
|
|
const changeOrAdded = require('./changeOrAdded');
|
|
|
|
const log = require('./log');
|
2016-10-24 05:48:27 +00:00
|
|
|
|
2017-05-10 15:19:59 +00:00
|
|
|
// Match only on .es6.js files.
|
2016-10-24 05:48:27 +00:00
|
|
|
const fileMatch = './**/*.es6.js';
|
2017-05-10 15:19:59 +00:00
|
|
|
// Ignore everything in node_modules
|
2016-10-24 05:48:27 +00:00
|
|
|
const globOptions = {
|
2017-05-10 15:19:59 +00:00
|
|
|
ignore: './node_modules/**'
|
2016-10-24 05:48:27 +00:00
|
|
|
};
|
|
|
|
const processFiles = (error, filePaths) => {
|
|
|
|
if (error) {
|
|
|
|
process.exitCode = 1;
|
|
|
|
}
|
2017-05-10 15:19:59 +00:00
|
|
|
// Process all the found files.
|
|
|
|
filePaths.forEach(changeOrAdded);
|
2016-10-24 05:48:27 +00:00
|
|
|
};
|
2017-05-10 15:19:59 +00:00
|
|
|
|
|
|
|
// Run build:js with some special arguments to only parse specific files.
|
|
|
|
// npm run build:js -- --files misc/drupal.es6.js misc/drupal.init.es6.js
|
|
|
|
// Only misc/drupal.es6.js misc/drupal.init.es6.js will be processed.
|
|
|
|
if (process.argv.length > 2 && process.argv[2] === '--files') {
|
|
|
|
processFiles(null, process.argv.splice(3, process.argv.length));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glob(fileMatch, globOptions, processFiles);
|
|
|
|
}
|
2016-10-24 05:48:27 +00:00
|
|
|
process.exitCode = 0;
|