2016-05-20 17:06:25 +00:00
|
|
|
/// <reference path="./typings/index.d.ts" />
|
|
|
|
let colors = require("colors");
|
2016-05-20 17:44:52 +00:00
|
|
|
let readline = require("readline");
|
|
|
|
|
2016-05-21 22:38:14 +00:00
|
|
|
let rl;
|
|
|
|
let initReadline = () => {
|
|
|
|
rl = readline.createInterface({
|
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
|
|
|
});
|
|
|
|
};
|
2016-05-20 17:06:25 +00:00
|
|
|
|
2016-05-21 18:33:13 +00:00
|
|
|
let moduleName:string;
|
|
|
|
let loaderLength:number;
|
|
|
|
let frameCounter:number = 0;
|
|
|
|
|
|
|
|
let makeFrame = ():string => {
|
|
|
|
let resultString:string = "["
|
|
|
|
+ "/".green.repeat(frameCounter)
|
|
|
|
+ " ".repeat(loaderLength - frameCounter)
|
|
|
|
+ "]"
|
|
|
|
+ " starting "
|
|
|
|
+ moduleName.cyan;
|
|
|
|
|
|
|
|
if(frameCounter == loaderLength){
|
|
|
|
frameCounter = 0;
|
|
|
|
} else {
|
|
|
|
frameCounter++;
|
|
|
|
}
|
|
|
|
return resultString;
|
|
|
|
};
|
|
|
|
|
|
|
|
let abort:boolean = true;
|
|
|
|
let logEarly = () => {
|
|
|
|
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
|
2016-05-21 22:38:14 +00:00
|
|
|
export let start = function(moduleNameArg:string = "",loaderLengthArg:number = 10){
|
2016-05-21 18:33:13 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
export let 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
|
|
|
};
|
|
|
|
|