UNPKG

liberty-prettydiff

Version:

Language aware code comparison tool for several web based languages. It also beautifies, minifies, and a few other things.

977 lines (974 loc) 443 kB
/*jslint node:true*/ /*jshint laxbreak: true*/ // The order array determines which tests run in which order (from last to first // index) (function taskrunner() { "use strict"; var order = [ "moduleInstall", "lint", // - run jslint on all unexcluded files in the repo "packagejson", // - beautify the package.json file and compare it to itself "coreunits", // - run a variety of files through the application and compare the result to a known good file //"diffunits", // - unit tests for the diff process "simulations" // - simulate a variety of execution steps and options from the command line ], text = { blue : "\u001b[34m", bold : "\u001b[1m", cyan : "\u001b[36m", green : "\u001b[32m", nocolor : "\u001b[39m", none : "\u001b[39m\u001b[0m", normal : "\u001b[0m", purple : "\u001b[35m", red : "\u001b[31m", underline: "\u001b[4m", yellow : "\u001b[33m" }, startTime = Date.now(), fs = require("fs"), path = require("path"), child = require("child_process").exec, abspath = (function taskrunner_abspath() { var absarr = process .argv[1] .split(path.sep); absarr.pop(); if (absarr[absarr.length - 1] === "test") { absarr.pop(); } if (absarr[absarr.length - 1] !== "prettydiff") { absarr.push("prettydiff"); } return absarr.join(path.sep) + path.sep; }()), humantime = function taskrunner_humantime(finished) { var minuteString = "", hourString = "", secondString = "", finalTime = "", finalMem = "", minutes = 0, hours = 0, elapsed = 0, memory = {}, prettybytes = function taskrunner_humantime_prettybytes(an_integer) { //find the string length of input and divide into triplets var length = an_integer .toString() .length, triples = (function taskrunner_humantime_prettybytes_triples() { if (length < 22) { return Math.floor((length - 1) / 3); } //it seems the maximum supported length of integer is 22 return 8; }()), //each triplet is worth an exponent of 1024 (2 ^ 10) power = (function taskrunner_humantime_prettybytes_power() { var a = triples - 1, b = 1024; if (triples === 0) { return 0; } if (triples === 1) { return 1024; } do { b = b * 1024; a -= 1; } while (a > 0); return b; }()), //kilobytes, megabytes, and so forth... unit = [ "", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ], output = ""; if (typeof an_integer !== "number" || isNaN(an_integer) === true || an_integer < 0 || an_integer % 1 > 0) { //input not a positive integer output = "0.00B"; } else if (triples === 0) { //input less than 1000 output = an_integer + "B"; } else { //for input greater than 999 length = Math.floor((an_integer / power) * 100) / 100; output = length.toFixed(2) + unit[triples]; } return output; }, plural = function core__proctime_plural(x, y) { var a = ""; if (x !== 1) { a = x + y + "s "; } else { a = x + y + " "; } return a; }, minute = function core__proctime_minute() { minutes = parseInt((elapsed / 60), 10); minuteString = (finished === true) ? plural(minutes, " minute") : (minutes < 10) ? "0" + minutes : "" + minutes; minutes = elapsed - (minutes * 60); secondString = (finished === true) ? (minutes === 1) ? " 1 second " : minutes.toFixed(3) + " seconds " : minutes.toFixed(3); }; memory = process.memoryUsage(); finalMem = prettybytes(memory.rss); //last line for additional instructions without bias to the timer elapsed = (Date.now() - startTime) / 1000; secondString = elapsed.toFixed(3); if (elapsed >= 60 && elapsed < 3600) { minute(); } else if (elapsed >= 3600) { hours = parseInt((elapsed / 3600), 10); elapsed = elapsed - (hours * 3600); hourString = (finished === true) ? plural(hours, " hour") : (hours < 10) ? "0" + hours : "" + hours; minute(); } else { secondString = (finished === true) ? plural(secondString, " second") : secondString; } if (finished === true) { finalTime = hourString + minuteString + secondString; console.log(finalMem + " of memory consumed"); console.log(finalTime + "total time"); console.log(""); } else { if (hourString === "") { hourString = "00"; } if (minuteString === "") { minuteString = "00"; } if ((/^([0-9]\.)/).test(secondString) === true) { secondString = "0" + secondString; } return "\u001B[36m[" + hourString + ":" + minuteString + ":" + secondString + "]\u001B[39m "; } }, prettydiff = require(abspath + "prettydiff.js"), options = {}, errout = function taskrunner_errout(errtext) { console.log(""); console.error(errtext); humantime(true); process.exit(1); }, diffFiles = function taskrunner_diffFiles(sampleName, sampleSource, sampleDiff) { var aa = 0, line = 0, pdlen = 0, count = 0, diffs = 0, lcount = 0, report = [], colors = { del : { charEnd : "\u001b[22m", charStart: "\u001b[1m", lineEnd : "\u001b[39m", lineStart: "\u001b[31m" }, filepath: { end : "\u001b[39m", start: "\u001b[36m" }, ins : { charEnd : "\u001b[22m", charStart: "\u001b[1m", lineEnd : "\u001b[39m", lineStart: "\u001b[32m" } }; options.mode = "diff"; options.source = sampleSource; options.diff = sampleDiff; options.diffcli = true; options.context = 2; options.lang = "text"; report = prettydiff(options)[0]; pdlen = report[0].length; if (report.length < 3) { console.log(""); console.log(colors.del.lineStart + "Test diff operation provided a bad code sample:" + colors.del.lineEnd); console.log(report[0]); return errout(colors.del.lineStart + "bad test" + colors.del.lineEnd); } // report indexes from diffcli feature of diffview.js 0 - source line number 1 - // source code line 2 - diff line number 3 - diff code line 4 - change 5 - index // of options.context (not parallel) 6 - total count of differences if (sampleName !== "phases.simulations" && report[0][0] < 2) { diffs += 1; console.log(""); console.log(colors.filepath.start + sampleName); console.log("Line: 1" + colors.filepath.end); } for (aa = 0; aa < pdlen; aa += 1) { if (report[4][aa] === "equal" && report[4][aa + 1] === "equal" && report[4][aa + 2] !== undefined && report[4][aa + 2] !== "equal") { count += 1; if (count === 51) { break; } line = report[0][aa] + 2; lcount = 0; diffs += 1; console.log(""); console.log(colors.filepath.start + sampleName); console.log("Line: " + line + colors.filepath.end); if (aa === 0) { console.log(report[3][aa]); console.log(report[3][aa + 1]); } } if (lcount < 7) { lcount += 1; if (report[4][aa] === "delete" && report[0][aa] !== report[0][aa + 1]) { if (report[1][aa] === "") { report[1][aa] = "(empty line)"; } else if (report[1][aa].replace(/\u0020+/g, "") === "") { report[1][aa] = "(indentation)"; } console.log(colors.del.lineStart + report[1][aa].replace(/<p(d)>/g, colors.del.charStart).replace(/<\/pd>/g, colors.del.charEnd) + colors.del.lineEnd); } else if (report[4][aa] === "insert" && report[2][aa] !== report[2][aa + 1]) { if (report[3][aa] === "") { report[3][aa] = "(empty line)"; } else if (report[3][aa].replace(/\u0020+/g, "") === "") { report[3][aa] = "(indentation)"; } console.log(colors.ins.lineStart + report[3][aa].replace(/<p(d)>/g, colors.ins.charStart).replace(/<\/pd>/g, colors.ins.charEnd) + colors.ins.lineEnd); } else if (report[4][aa] === "equal" && aa > 1) { console.log(report[3][aa]); } else if (report[4][aa] === "replace") { console.log(colors.del.lineStart + report[1][aa].replace(/<p(d)>/g, colors.del.charStart).replace(/<\/pd>/g, colors.del.charEnd) + colors.del.lineEnd); console.log(colors.ins.lineStart + report[3][aa].replace(/<p(d)>/g, colors.ins.charStart).replace(/<\/pd>/g, colors.ins.charEnd) + colors.ins.lineEnd); } } } if (sampleName !== "phases.simulations") { console.log(""); console.log(diffs + colors.filepath.start + " differences counted." + colors.filepath.end); errout("Pretty Diff " + colors.del.lineStart + "failed" + colors.del.lineEnd + " on file: " + colors.filepath.start + sampleName + colors.filepath.end); } }, longname = 0, namepad = function taskrunner_namepad(name) { var a = name.length; if (name.length === longname) { return name; } do { a += 1; name = name + " "; } while (a < longname); return name; }, modules = { jslint : { dir : "JSLint", edition: function taskrunner_lint_modules_jslint(obj) { console.log("* " + text.bold + text.green + namepad(obj.name) + text.none + " - " + obj.app().edition); }, file : "jslint.js", name : "JSLint", repo : "https://github.com/douglascrockford/JSLint.git" } }, keys = Object.keys(modules), phases = {}, next = function taskrunner_next() { console.log(""); if (order.length < 1) { return humantime(true); } phases[order[0]](); order.splice(0, 1); }; phases.coreunits = function taskrunner_coreunits() { var raw = [], correct = [], countr = 0, countc = 0, utflag = { correct: false, raw : false }, sort = function taskrunner_coreunits_sort(a, b) { if (a > b) { return 1; } return -1; }, compare = function taskrunner_coreunits_compare() { var len = (raw.length > correct.length) ? raw.length : correct.length, a = 0, output = "", filecount = 0; raw.sort(sort); correct.sort(sort); options = { correct : true, crlf : false, html : true, inchar : " ", insize : 4, lang : "auto", methodchain : "indent", mode : "beautify", nocaseindent: false, objsort : "all", preserve : 2, quoteConvert: "double", spaceclose : true, varword : "none", vertical : "all", wrap : 80 }; for (a = 0; a < len; a += 1) { if (raw[a] === undefined || correct[a] === undefined) { if (raw[a] === undefined) { console.log("\u001B[33msamples_raw directory is missing file:\u001B[39m " + correct[a][0]); correct.splice(a, 1); } else { console.log("\u001B[33msamples_correct directory is missing file:\u001B[39m " + raw[a][0]); raw.splice(a, 1); } len = (raw.length > correct.length) ? raw.length : correct.length; a -= 1; if (a === len - 1) { console.log(""); console.log("\u001B[32mCore Unit Testing Complete\u001B[39m"); return next(); } } else if (raw[a][0] === correct[a][0]) { options.source = raw[a][1]; output = prettydiff(options); if (output.charAt(output.length - 1) !== "\n") { output = output + "\n"; } if (output === correct[a][1]) { filecount += 1; console.log(humantime(false) + "\u001B[32mPass " + filecount + ":\u001B[39m " + correct[a][0]); if (a === len - 1) { return next(); } } else { diffFiles(correct[a][0], output, correct[a][1]); } } else { if (raw[a][0] < correct[a][0]) { console.log("\u001B[33mCorrect samples directory is missing file:\u001B[39m " + raw[a][0]); raw.splice(a, 1); } else { console.log("\u001B[33mRaw samples directory is missing file:\u001B[39m " + correct[a][0]); correct.splice(a, 1); } len = (raw.length > correct.length) ? raw.length : correct.length; a -= 1; if (a === len - 1) { return next(); } } } }, readDir = function taskrunner_coreunits_readDir(type) { var dirpath = __dirname + "/samples_" + type; fs.readdir(dirpath, function taskrunner_coreunits_readDir_callback(err, list) { var pusher = function taskrunner_coreunits_readDir_callback_pusher(val, ind, arr) { fs .readFile(__dirname + "/samples_" + type + "/" + val, "utf8", function taskrunner_coreunits_readDir_callback_pusher_readFile(erra, fileData) { if (erra !== null && erra !== undefined) { errout("Error reading file: " + __dirname + "/samples_" + type + "/" + val); } else if (type === "raw") { raw.push([val, fileData]); countr += 1; if (countr === arr.length) { utflag.raw = true; if (utflag.correct === true) { compare(""); } } } else if (type === "correct") { correct.push([val, fileData]); countc += 1; if (countc === arr.length) { utflag.correct = true; if (utflag.raw === true) { compare(""); } } } return ind; }); }; if (err !== null) { errout("Error reading from directory: /samples_" + type); } list.forEach(pusher); }); }; console.log(""); console.log(""); console.log("\u001B[36mCore Unit Testing\u001B[39m"); readDir("raw"); readDir("correct"); }; phases.diffunits = function taskrunner_diffunits() { return; }; phases.lint = function taskrunner_lint() { var ignoreDirectory = [ ".vscode", "ace", "bin", "coverage", "guide", "ignore", "JSLint", "node_modules", "test/samples_correct", "test/samples_raw" ], flag = { files: false, fs : false, items: false, lint : false, today: false }, files = [], lintrun = function taskrunner_lint_lintrun() { var lintit = function taskrunner_lint_lintrun_lintit(val, ind, arr) { var result = {}, failed = false, ecount = 0, report = function taskrunner_lint_lintrun_lintit_lintOn_report(warning) { //start with an exclusion list. There are some warnings that I don't care about if (warning === null) { return; } if (warning.message.indexOf("Unexpected dangling '_'") === 0) { return; } if ((/Bad\u0020property\u0020name\u0020'\w+_'\./).test(warning.message) === true) { return; } if (warning.message.indexOf("/*global*/ requires") === 0) { return; } failed = true; if (ecount === 0) { console.log("\u001B[31mJSLint errors on\u001B[39m " + val[0]); console.log(""); } ecount += 1; console.log("On line " + warning.line + " at column: " + warning.column); console.log(warning.message); console.log(""); }; options.source = val[1]; result = modules.jslint.app(prettydiff(options), {"for": true}); if (result.ok === true) { console.log(humantime(false) + "\u001B[32mLint is good for file " + (ind + 1) + ":\u001B[39m " + val[0]); if (ind === arr.length - 1) { console.log(""); console.log("\u001B[32mLint operation complete!\u001B[39m"); console.log(""); return next(); } } else { result .warnings .forEach(report); if (failed === true) { errout("\u001B[31mLint fail\u001B[39m :("); } else { console.log(humantime(false) + "\u001B[32mLint is good for file " + (ind + 1) + ":\u001B[39m " + val[0]); if (ind === arr.length - 1) { console.log(""); console.log("\u001B[32mLint operation complete!\u001B[39m"); console.log(""); return next(); } } } }; options = { correct : false, crlf : false, html : true, inchar : " ", insize : 4, lang : "javascript", methodchain : false, mode : "beautify", nocaseindent: false, objsort : "all", preserve : true, styleguide : "jslint", wrap : 80 }; files.forEach(lintit); }; console.log(""); console.log(""); console.log("\u001B[36mBeautifying and Linting\u001B[39m"); console.log("** Note that line numbers of error messaging reflects beautified code line."); console.log(""); (function taskrunner_lint_getFiles() { var fc = 0, ft = 0, total = 0, count = 0, idLen = ignoreDirectory.length, readFile = function taskrunner_lint_getFiles_readFile(filePath) { fs .readFile(filePath, "utf8", function taskrunner_lint_getFiles_readFile_callback(err, data) { if (err !== null && err !== undefined) { errout(err); } fc += 1; if (ft === fc) { flag.files = true; } if (path.sep === "\\") { files.push([ filePath.slice(filePath.indexOf("\\prettydiff\\") + 14), data ]); } else { files.push([ filePath.slice(filePath.indexOf("/prettydiff/") + 12), data ]); } if (flag.files === true && flag.items === true) { flag.files = false; lintrun(); } }); }, readDir = function taskrunner_lint_getFiles_readDir(path) { fs .readdir(path, function taskrunner_lint_getFiles_readDir_callback(erra, list) { var fileEval = function taskrunner_lint_getFiles_readDir_callback_fileEval(val) { var filename = path + "/" + val; fs.stat(filename, function taskrunner_lint_getFiles_readDir_callback_fileEval_stat(errb, stat) { var a = 0, ignoreDir = false; if (errb !== null) { return errout(errb); } count += 1; if (count === total) { flag.items = true; } if (stat.isFile() === true && (/(\.js)$/).test(val) === true) { ft += 1; readFile(filename); } if (stat.isDirectory() === true) { do { if (val === ignoreDirectory[a]) { ignoreDir = true; break; } a += 1; } while (a < idLen); if (ignoreDir === true) { if (flag.files === true && flag.items === true) { flag.items = false; lintrun(); } } else { taskrunner_lint_getFiles_readDir(filename); } } }); }; if (erra !== null) { return errout("Error reading path: " + path + "\n" + erra); } total += list.length; list.forEach(fileEval); }); }; readDir(__dirname.replace(/((\/|\\)test)$/, "")); }()); }; phases.moduleInstall = function taskrunner_moduleInstall() { var dateobj = new Date(), day = (dateobj.getDate() > 9) ? "" + dateobj.getDate() : "0" + dateobj.getDate(), month = (dateobj.getMonth() > 8) ? "" + (dateobj.getMonth() + 1) : "0" + (dateobj.getMonth() + 1), date = Number("" + dateobj.getFullYear() + month + day), ind = 0, flag = { apps : false, jslint: false, modout: false, today : false }, todaypath = abspath + "test" + path.sep + "today.js", today = require(todaypath), editions = function taskrunner_moduleInstall_editionsInit() { return; }, handler = function taskrunner_moduleInstall_handler() { var mod = keys[ind]; if (modules[mod].name.length > longname) { longname = modules[mod].name.length; } fs .stat(modules[mod].dir, function taskrunner_moduleInstall_handler_stat(erstat, stats) { var add = function taskrunner_moduleInstall_handler_stat_add() { console.log("Adding " + modules[mod].name); child("git submodule add " + modules[mod].repo, function taskrunner_moduleInstall_handler_stat_add_submodule(era, stdouta, stdoutera) { if (era !== null && era.toString().indexOf("already exists in the index") < 0) { errout(era); } if (stdoutera !== null && stdoutera !== "" && stdoutera.indexOf("Cloning into '") < 0 && stdoutera.indexOf("already exists in the index") < 0) { errout(stdoutera); } child("git clone " + modules[mod].repo, function taskrunner_moduleInstall_handler_stat_add_submodule_clone(erb, stdoutb, stdouterb) { if (erb !== null) { errout(erb); } if (stdouterb !== null && stdouterb !== "" && stdouterb.indexOf("Cloning into '") < 0) { errout(stdouterb); } ind += 1; editions(mod, true, ind); return stdoutb; }); return stdouta; }); }; if (erstat !== null && erstat !== undefined) { if (erstat.toString().indexOf("Error: ENOENT: no such file or directory, stat '") === 0) { return add(); } errout(erstat); } if (stats.isDirectory() === true) { return fs .readdir(modules[mod].dir, function taskrunner_moduleInstall_handler_stat_readdir(direrr) { if (direrr !== null) { errout(direrr); } ind += 1; editions(mod, false); }); } add(); }); }; editions = function taskrunner_moduleInstall_editions(appName, cloned) { var modout = function taskrunner_moduleInstall_editions_modout() { var x = 0, len = keys.length; console.log("Installed submodule versions"); console.log("----------------------------"); for (x = 0; x < len; x += 1) { modules[keys[x]].edition(modules[keys[x]]); } next(); }, submod = function taskrunner_moduleInstall_editions_submod(output) { var appFile = abspath + modules[appName].dir + path.sep + modules[appName].file, jslintcomplete = function taskrunner_moduleInstall_editions_submod_jslintcomplete() { modules.jslint.app = require(appFile); flag.jslint = true; if (ind === keys.length) { if (flag.today === true && flag.modout === false) { modout(); } else { if (output === true) { console.log("All submodules configured."); } flag.apps = true; } } }; if (appName === "jslint") { fs .readFile(appFile, "utf8", function taskrunner_moduleInstall_editions_submod_lintread(erread, data) { if (erread !== null && erread !== undefined) { errout(erread); } if (data.slice(data.length - 30).indexOf("\nmodule.exports = jslint;") < 0) { data = data + "\nmodule.exports = jslint;"; fs .writeFile(appFile, data, "utf8", function taskrunner_moduleInstall_editions_submod_lintread_lintwrite(erwrite) { if (erwrite !== null && erwrite !== undefined) { errout(erwrite); } jslintcomplete(); }); } else { jslintcomplete(); } }); } else { modules[appName].app = require(appFile); if (ind === keys.length && flag.jslint === true) { if (flag.today === true) { flag.modout = true; modout(); } else { if (output === true) { console.log("All submodules configured."); } flag.apps = true; } } } }, each = function taskrunner_moduleInstall_editions_each(val, idx) { appName = val; ind = idx + 1; submod(false); }, update = function taskrunner_moduleInstall_editions_update() { child("git submodule update", function taskrunner_moduleInstall_editions_update_child(erd, stdoutd, stdouterd) { if (erd !== null) { errout(erd); } if (stdouterd !== null && stdouterd !== "" && stdouterd.indexOf("Cloning into '") < 0 && stdouterd.indexOf("From ") !== 0) { errout(stdouterd); } if (flag.today === false) { console.log("Submodules downloaded."); } keys.forEach(each); return stdoutd; }); }, pull = function taskrunner_moduleInstall_editions_pull() { child("git stash", { cwd: "JSLint" }, function taskrunner_moduleInstall_editions_pull_stash(errstash, stdoutstash, stdouterstash) { if (errstash !== null) { return errout(errstash); } if (stdouterstash !== null && stdouterstash !== "") { return errout(stdouterstash); } child("git submodule foreach git pull origin master", function taskrunner_moduleInstall_editions_pull_stash_pullit(errpull, stdoutpull, stdouterpull) { if (errpull !== null) { console.log(errpull); if (errpull.toString().indexOf("fatal: no submodule mapping found in .gitmodules for path ") > 0) { console.log("No access to GitHub or .gitmodules is corrupt. Proceeding assuming submodules we" + "re previously installed."); flag.apps = true; return keys.forEach(each); } errout(errpull); } if (stdouterpull !== null && stdouterpull !== "" && stdouterpull.indexOf("Cloning into '") < 0 && stdouterpull.indexOf("From ") < 0 && stdouterpull.indexOf("fatal: no submodule mapping found in .gitmodules for path ") < 0) { errout(stdouterpull); } if (flag.today === false) { console.log("Submodules checked for updates."); } keys.forEach(each); return stdoutpull; }); return stdoutstash; }); }; if (ind === keys.length) { if (today !== date) { child("git checkout jslint.js", { cwd: "JSLint" }, function taskrunner_moduleInstall_editions_checkoutJSLint(erjsl, stdoutjsl, stdouterjsl) { if (erjsl !== null) { errout(erjsl); } if (stdouterjsl !== null && stdouterjsl !== "") { errout(stdouterjsl); } ind = 0; fs .writeFile(todaypath, "/\u002aglobal module\u002a/(function () {\"use strict\";var today=" + date + ";module.exports=today;}());", function taskrunner_moduleInstall_editions_checkoutJSLint_writeToday(werr) { if (werr !== null && werr !== undefined) { errout(werr); } if (cloned === true) { console.log("Submodules downloaded."); } else { console.log("Submodules checked for updates."); } if (flag.apps === true) { modout(); } else { console.log("Checked for new versions of submodules."); flag.today = true; } }); if (cloned === true) { child("git submodule init", function taskrunner_moduleInstall_editions_checkoutJSLint_init(erc, stdoutc, stdouterc) { if (erc !== null) { errout(erc); } if (stdouterc !== null && stdouterc !== "" && stdouterc.indexOf("Cloning into '") < 0 && stdouterc.indexOf("From ") < 0 && stdouterc.indexOf(" registered for path ") < 0) { errout(stdouterc); } update(); return stdoutc; }); } pull(); return stdoutjsl; }); } else { flag.today = true; console.log("Running prior installed modules."); keys.forEach(each); } } else { handler(ind); } }; handler(0); }; phases.packagejson = function taskrunner_packagejson() { fs .readFile("package.json", "utf8", function taskrunner_packagejson_readFile(err, data) { var prettydata = "", globalmeta = "{\"difflines\":0,\"difftotal\":0,\"error\":\"\",\"insize\":xxx,\"lang\":[\"json" + "\",\"json\",\"JSON\"],\"outsize\":xxx,\"time\":\"0.000 seconds\"}", strmeta = ""; if (err !== null && err !== undefined) { errout("Cannot read package.json"); } if (data.indexOf("_requiredBy") > 0) { return next(); } console.log(""); console.log("\u001B[36mTesting package.json beautification...\u001B[39m"); options.lang = "auto"; options.mode = "beautify"; options.objsort = "all"; options.source = data; options.styleguide = "none"; options.vertical = "all"; prettydata = prettydiff(options); strmeta = JSON .stringify(global.prettydiff.meta) .replace(/size":\d+/g, "size\":xxx") .replace(/\d+\.\d+\u0020seconds/, "0.000 seconds"); if (data.replace(/(\s+)$/, "") !== prettydata.replace(/(\s+)$/, "")) { diffFiles("package.json", data, prettydata); errout("\u001B[31mPretty Diff corrupted package.json\u001B[36m"); } console.log(humantime(false) + "\u001B[32mThe package.json file is beautified properly.\u001B[36m"); if (strmeta !== globalmeta) { diffFiles("package.json", strmeta, globalmeta); errout("\u001B[31mglobal.prettydiff.meta is broken from package.json beautification.1B[3" + "9m"); console.log(""); } console.log(humantime(false) + "\u001B[32mglobal.prettydiff.meta global object is properly constructed.\u001B[39" + "m"); return next(); }); }; phases.simulations = function taskrunner_simulations() { var passcount = [], //passing tests in local group finished = [], //completed tests in local group grouplen = [], //length of local group groupname = [], //name of current group teardowns = [], //a list of tear down lists units = [], //test unit arrays index = [], //current array index of current group total = 0, //total number of tests gcount = 0, //total number of groups fgroup = 0, //total number of groups containing failed tests fails = 0, //total number of failed tests depth = -1, //current depth single = false, //look for the unit test file tablen = 2, //size of indentation in spaces tests = [ { buildup : [ function taskrunner_simulations_buildup0() { fs .mkdir("test/simulation", function taskrunner_simulations_buildup0_callback(err) { if (err !== null) { return errout(err); } }); }, "echo \"<a><b> <c/> </b></a>\" > test/simulation/testa.txt", "echo \"<a><b> <d/> </b></a>\" > test/simulation/testb.txt", "echo \"\" > test/simulation/testa1.txt", "echo \"\" > test/simulation/testb1.txt", "echo \"some simple text for an example\" > test/simulation/testc1.txt", "echo \"\" > test/simulation/testd1.txt" ], group : "api simulation - node-local.js", teardown: ["rm -rf test/simulation", "rm -rf JSLint"], units : [ { group: "readmethod: screen", units: [ { check : "node api/node-local.js source:\"<a><b> <c/> </b></a>\" readmethod:\"screen\" " + "mode:\"beautify\"", name : "Beautify markup.", verify: "<a>\n <b>\n <c/>\n </b>\n</a>" }, { check : "node api/node-local.js source:\"<a><b> <c/> </b></a>\" readmethod:\"screen\" " + "mode:\"minify\"", name : "Minify markup.", verify: "<a><b> <c/> </b></a>" }, { check : "node api/node-local.js source:\"<a><b> <c/> </b></a>\" readmethod:\"screen\" " + "mode:\"parse\"", name : "Parse markup.", verify: "{\"data\":{\"attrs\":[{},{},{},{},{}],\"begin\":[0,0,1,1,0],\"daddy\":[\"root\"," + "\"a\",\"b\",\"b\",\"a\"],\"jscom\":[false,false,false,false,false],\"linen\":[1," + "1,1,1,1],\"lines\":[0,0,1,1,0],\"presv\":[false,false,false,false,false],\"token" + "\":[\"<a>\",\"<b>\",\"<c/>\",\"</b>\",\"</a>\"],\"types\":[\"start\",\"start\"," + "\"singleton\",\"end\",\"end\"]},\"definition\":{\"attrs\":\"array - List of attr" + "ibutes (if any) for the given token.\",\"begin\":\"number - Index where the pare" + "nt element occurs.\",\"daddy\":\"string - Tag name of the parent element. Tokens" + " of type 'template_start' are not considered as parent elements. End tags refle" + "ct their matching start tag.\",\"jscom\":\"boolean - Whether the token is a Java" + "Script comment if in JSX format.\",\"linen\":\"number - The line number in the o" + "riginal source where the token started, which is used for reporting and analysis" + ".\",\"lines\":\"number - Whether the token is preceeded any space and/or line br" + "eaks in the original code source.\",\"presv\":\"boolean - Whether the token is p" + "reserved verbatim as found. Useful for comments and HTML 'pre' tags.\",\"token" + "\":\"string - The parsed code tokens.\",\"types\":\"string - Data types of the t" +