X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fscripts%2Fjs%2Fcheck.js;fp=web%2Fcore%2Fscripts%2Fjs%2Fcheck.js;h=8769d64e94c7affce4786a7749c698141a690a98;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/scripts/js/check.js b/web/core/scripts/js/check.js new file mode 100644 index 000000000..8769d64e9 --- /dev/null +++ b/web/core/scripts/js/check.js @@ -0,0 +1,23 @@ +const chalk = require('chalk'); +const fs = require('fs'); +const log = require('./log'); +const compile = require('./compile'); + +module.exports = (filePath) => { + log(`'${filePath}' is being checked.`); + // Transform the file. + compile(filePath, function check(code) { + const fileName = filePath.slice(0, -7); + fs.readFile(`${fileName}.js`, function read(err, data) { + if (err) { + log(chalk.red(err)); + process.exitCode = 1; + return; + } + if (code !== data.toString()) { + log(chalk.red(`'${filePath}' is not updated.`)); + process.exitCode = 1; + } + }); + }); +}