Security update for Core, with self-updated composer
[yaffs-website] / web / core / scripts / js / compile.js
1 const chalk = require('chalk');
2 const log = require('./log');
3 const babel = require('babel-core');
4
5 module.exports = (filePath, callback) => {
6   // Transform the file.
7   // Check process.env.NODE_ENV to see if we should create sourcemaps.
8   babel.transformFile(
9     filePath,
10     {
11       sourceMaps: process.env.NODE_ENV === 'development' ? 'inline' : false,
12       comments: false,
13       plugins: [
14         ['add-header-comment', {
15           'header': [
16             `DO NOT EDIT THIS FILE.\nSee the following change record for more information,\nhttps://www.drupal.org/node/2815083\n@preserve`
17           ]
18         }]
19       ]
20     },
21     (err, result) => {
22       if (err) {
23         log(chalk.red(err));
24         process.exitCode = 1;
25       }
26       else {
27         callback(result.code);
28       }
29     }
30   );
31 };