Move all files to 2017/
This commit is contained in:
parent
ac7370f67f
commit
2875863330
15717 changed files with 0 additions and 0 deletions
43
2017/web/core/scripts/js/babel-es6-watch.js
Normal file
43
2017/web/core/scripts/js/babel-es6-watch.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* Watch changes to *.es6.js files and compile them to ES5 during development.
|
||||
*
|
||||
* @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 chokidar = require('chokidar');
|
||||
|
||||
const changeOrAdded = require('./changeOrAdded');
|
||||
const log = require('./log');
|
||||
|
||||
// Match only on .es6.js files.
|
||||
const fileMatch = './**/*.es6.js';
|
||||
// Ignore everything in node_modules
|
||||
const watcher = chokidar.watch(fileMatch, {
|
||||
ignoreInitial: true,
|
||||
ignored: './node_modules/**'
|
||||
});
|
||||
|
||||
const unlinkHandler = (err) => {
|
||||
if (err) {
|
||||
log(err);
|
||||
}
|
||||
};
|
||||
|
||||
// Watch for filesystem changes.
|
||||
watcher
|
||||
.on('add', changeOrAdded)
|
||||
.on('change', changeOrAdded)
|
||||
.on('unlink', (filePath) => {
|
||||
const fileName = filePath.slice(0, -7);
|
||||
fs.stat(`${fileName}.js`, () => {
|
||||
fs.unlink(`${fileName}.js`, unlinkHandler);
|
||||
});
|
||||
})
|
||||
.on('ready', () => log(`Watching '${fileMatch}' for changes.`));
|
Reference in a new issue