JAVASCRIPT 7
Compile.js Guest on 20th November 2020 05:23:17 AM
  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\[email protected]`
  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. };

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Recent Pastes

Raw Paste

Login or Register to edit or fork this paste. It's free.