45 lines
3.0 KiB
JavaScript
45 lines
3.0 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
const chalk = require("chalk");
|
|
const readline = require("readline");
|
|
let rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout
|
|
});
|
|
let moduleName;
|
|
let loaderLength;
|
|
let frameCounter = 0;
|
|
let makeFrame = () => {
|
|
let resultString = `[${chalk.green('/'.repeat(frameCounter))}${' '.repeat(loaderLength - frameCounter)}] starting ${moduleName}`;
|
|
if (frameCounter === loaderLength) {
|
|
frameCounter = 0;
|
|
}
|
|
else {
|
|
frameCounter++;
|
|
}
|
|
return resultString;
|
|
};
|
|
let logEarlyAbort = false;
|
|
let logEarly = () => {
|
|
if (!logEarlyAbort) {
|
|
rl.write(null, { ctrl: true, name: 'u' });
|
|
rl.write(makeFrame());
|
|
setTimeout(function () {
|
|
logEarly();
|
|
}, 80);
|
|
}
|
|
else {
|
|
readline.clearLine(process.stdout, 0);
|
|
process.exit(0);
|
|
}
|
|
};
|
|
let start = function (moduleNameArg = '', loaderLengthArg = '10') {
|
|
moduleName = moduleNameArg;
|
|
loaderLength = parseInt(loaderLengthArg);
|
|
logEarly();
|
|
};
|
|
process.on('SIGINT', () => {
|
|
logEarlyAbort = true;
|
|
});
|
|
start();
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWFybHkuY2hpbGQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9lYXJseS5jaGlsZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLCtCQUErQjtBQUMvQixxQ0FBcUM7QUFDckMsSUFBSSxFQUFFLEdBQUcsUUFBUSxDQUFDLGVBQWUsQ0FBQztJQUM5QixLQUFLLEVBQUUsT0FBTyxDQUFDLEtBQUs7SUFDcEIsTUFBTSxFQUFFLE9BQU8sQ0FBQyxNQUFNO0NBQ3pCLENBQUMs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