early/dist/early.child.js
2016-06-10 05:59:21 +02:00

51 lines
5.0 KiB
JavaScript

"use strict";
require("typings-global");
var colors = require("colors");
var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var moduleName;
var loaderLength;
var frameCounter = 0;
var makeFrame = function () {
var resultString = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if (frameCounter == loaderLength) {
frameCounter = 0;
}
else {
frameCounter++;
}
return resultString;
};
var logEarlyAbort = false;
var logEarly = function () {
rl.write(null, { ctrl: true, name: 'u' });
rl.write(makeFrame());
setTimeout(function () {
if (!logEarlyAbort)
logEarly();
}, 80);
};
var start = function (moduleNameArg, loaderLengthArg) {
if (moduleNameArg === void 0) { moduleNameArg = ""; }
if (loaderLengthArg === void 0) { loaderLengthArg = "10"; }
moduleName = moduleNameArg;
loaderLength = parseInt(loaderLengthArg);
logEarly();
};
start(process.env.moduleNameArg, process.env.loaderLengthArg);
process.on('SIGINT', function () {
logEarlyAbort = true;
rl.write(null, { ctrl: true, name: 'u' });
rl.close();
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVhcmx5LmNoaWxkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLElBQU8sUUFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQ3RDLElBQUksRUFBRSxHQUFHLFFBQVEsQ0FBQyxlQUFlLENBQUM7SUFDOUIsS0FBSyxFQUFFLE9BQU8sQ0FBQyxLQUFLO0lBQ3BCLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTTtDQUN6QixDQUFDLENBQUM7QUFFSCxJQUFJLFVBQWlCLENBQUM7QUF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