early/dist/index.js

65 lines
6.0 KiB
JavaScript
Raw Normal View History

2016-05-20 17:06:25 +00:00
"use strict";
/// <reference path="./typings/index.d.ts" />
2016-05-20 17:44:52 +00:00
var colors = require("colors");
var readline = require("readline");
2016-05-21 22:38:14 +00:00
var rl;
var initReadline = function () {
rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
};
2016-05-21 18:33:13 +00:00
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 abort = true;
var logEarly = function () {
rl.write(null, { ctrl: true, name: 'u' });
rl.write(makeFrame());
2016-05-20 17:44:52 +00:00
setTimeout(function () {
2016-05-21 18:33:13 +00:00
if (!abort) {
logEarly();
}
}, 200);
};
// exports
exports.start = function (moduleNameArg, loaderLengthArg) {
2016-05-21 22:38:14 +00:00
if (moduleNameArg === void 0) { moduleNameArg = ""; }
2016-05-21 18:33:13 +00:00
if (loaderLengthArg === void 0) { loaderLengthArg = 10; }
abort = false;
moduleName = moduleNameArg;
loaderLength = loaderLengthArg;
2016-05-21 22:38:14 +00:00
if (!process.env.CI) {
initReadline();
logEarly();
}
else {
console.log("**** starting " + moduleName + " ****");
}
;
2016-05-20 17:06:25 +00:00
};
exports.stop = function () {
2016-05-21 18:33:13 +00:00
abort = true;
2016-05-21 22:38:14 +00:00
if (!process.env.CI) {
rl.write(null, { ctrl: true, name: 'u' });
rl.close();
}
2016-05-20 17:06:25 +00:00
};
2016-05-21 22:38:14 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTy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