2016-06-10 03:18:03 +00:00
|
|
|
import "typings-global";
|
2016-08-20 05:03:49 +00:00
|
|
|
import chalk = require("chalk");
|
2016-05-23 02:40:04 +00:00
|
|
|
import readline = require("readline");
|
2016-06-10 03:59:21 +00:00
|
|
|
let rl = readline.createInterface({
|
2016-05-23 02:40:04 +00:00
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
2016-06-10 03:59:21 +00:00
|
|
|
});
|
2016-05-23 02:40:04 +00:00
|
|
|
|
2016-08-20 05:03:49 +00:00
|
|
|
let moduleName: string;
|
|
|
|
let loaderLength: number;
|
|
|
|
let frameCounter: number = 0;
|
2016-05-23 02:40:04 +00:00
|
|
|
|
2016-08-20 05:03:49 +00:00
|
|
|
let makeFrame = (): string => {
|
|
|
|
let resultString: string = `[${chalk.green("/".repeat(frameCounter))}${" ".repeat(loaderLength - frameCounter)}] starting ${moduleName}`;
|
|
|
|
if (frameCounter == loaderLength) {
|
2016-05-23 02:40:04 +00:00
|
|
|
frameCounter = 0;
|
|
|
|
} else {
|
|
|
|
frameCounter++;
|
|
|
|
}
|
|
|
|
return resultString;
|
|
|
|
};
|
|
|
|
|
2016-06-10 03:59:21 +00:00
|
|
|
let logEarlyAbort = false;
|
2016-05-23 02:40:04 +00:00
|
|
|
let logEarly = () => {
|
2016-08-20 05:03:49 +00:00
|
|
|
if (!logEarlyAbort) {
|
|
|
|
rl.write(null, { ctrl: true, name: 'u' });
|
|
|
|
rl.write(makeFrame());
|
|
|
|
setTimeout(function () {
|
|
|
|
logEarly();
|
|
|
|
}, 80);
|
|
|
|
}
|
2016-05-23 02:40:04 +00:00
|
|
|
};
|
|
|
|
|
2016-08-20 05:03:49 +00:00
|
|
|
let start = function (moduleNameArg: string = "", loaderLengthArg: string = "10") {
|
2016-05-23 02:40:04 +00:00
|
|
|
moduleName = moduleNameArg;
|
|
|
|
loaderLength = parseInt(loaderLengthArg);
|
2016-06-10 03:36:06 +00:00
|
|
|
logEarly();
|
2016-05-23 02:40:04 +00:00
|
|
|
};
|
|
|
|
|
2016-08-20 05:03:49 +00:00
|
|
|
start(process.env.moduleNameArg, process.env.loaderLengthArg);
|
2016-06-10 03:59:21 +00:00
|
|
|
|
2016-08-20 05:41:56 +00:00
|
|
|
process.on('SIGINT', () => {
|
2016-06-10 03:59:21 +00:00
|
|
|
logEarlyAbort = true;
|
2016-08-20 05:03:49 +00:00
|
|
|
rl.write(null, { ctrl: true, name: 'u' });
|
2016-08-20 07:09:03 +00:00
|
|
|
process.exit(0);
|
2016-06-10 03:59:21 +00:00
|
|
|
});
|