JAVASCRIPT 8
Check.js Guest on 20th November 2020 05:23:52 AM
  1. const chalk = require('chalk');
  2. const fs = require('fs');
  3. const log = require('./log');
  4. const compile = require('./compile');
  5.  
  6. module.exports = (filePath) => {
  7.   log(`'${filePath}' is being checked.`);
  8.   // Transform the file.
  9.   compile(filePath, function check(code) {
  10.     const fileName = filePath.slice(0, -7);
  11.     fs.readFile(`${fileName}.js`, function read(err, data) {
  12.       if (err) {
  13.         log(chalk.red(err));
  14.         process.exitCode = 1;
  15.         return;
  16.       }
  17.       if (code !== data.toString()) {
  18.         log(chalk.red(`'${filePath}' is not updated.`));
  19.         process.exitCode = 1;
  20.       }
  21.     });
  22.   });
  23. }

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.