summaryrefslogtreecommitdiffstatshomepage
path: root/core/scripts/js/jqueryui-check.js
blob: 3b7c97cc5518b7791d636104c3374d6fa469dd9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const chalk = require('chalk');
const fs = require('fs');
const log = require('./log');
const Terser = require('terser');

module.exports = filePath => {
  log(`'${filePath}' is being checked.`);
  // Transform the file.
  const file = fs.readFileSync(filePath, 'utf-8');
  Terser.minify(file).then((result) => {
    const fileName = filePath.slice(0, -3);
    fs.readFile(`${fileName}-min.js`, function read(err, data) {
      if (err) {
        log(chalk.red(err));
        process.exitCode = 1;
        return;
      }
      if (result.code !== data.toString()) {
        log(chalk.red(`'${filePath}' is not updated.`));
        process.exitCode = 1;
      }
    });
  });
};