2016-09-18 21:11:26 +00:00
|
|
|
import 'typings-global'
|
|
|
|
import chalk = require('chalk')
|
|
|
|
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-09-18 21:11:26 +00:00
|
|
|
})
|
2016-05-23 02:40:04 +00:00
|
|
|
|
2016-09-18 21:11:26 +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 => {
|
2016-09-18 21:11:26 +00:00
|
|
|
let resultString: string = `[${chalk.green('/'.repeat(frameCounter))}${' '.repeat(loaderLength - frameCounter)}] starting ${moduleName}`
|
|
|
|
if (frameCounter === loaderLength) {
|
|
|
|
frameCounter = 0
|
2016-05-23 02:40:04 +00:00
|
|
|
} else {
|
2016-09-18 21:11:26 +00:00
|
|
|
frameCounter++
|
2016-05-23 02:40:04 +00:00
|
|
|
}
|
2016-09-18 21:11:26 +00:00
|
|
|
return resultString
|
|
|
|
}
|
2016-05-23 02:40:04 +00:00
|
|
|
|
2016-09-18 21:11:26 +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) {
|
2016-09-18 21:11:26 +00:00
|
|
|
rl.write(null, { ctrl: true, name: 'u' })
|
|
|
|
rl.write(makeFrame())
|
2016-08-20 05:03:49 +00:00
|
|
|
setTimeout(function () {
|
2016-09-18 21:11:26 +00:00
|
|
|
logEarly()
|
|
|
|
}, 80)
|
|
|
|
} else {
|
2016-09-18 21:44:56 +00:00
|
|
|
rl.write(null, { ctrl: true, name: 'u' })
|
|
|
|
rl.close()
|
|
|
|
setTimeout(function () {
|
|
|
|
process.exit(0)
|
|
|
|
}, 80)
|
2016-08-20 05:03:49 +00:00
|
|
|
}
|
2016-09-18 21:11:26 +00:00
|
|
|
}
|
2016-05-23 02:40:04 +00:00
|
|
|
|
2016-09-18 21:11:26 +00:00
|
|
|
let start = function (moduleNameArg: string = '', loaderLengthArg: string = '10') {
|
|
|
|
moduleName = moduleNameArg
|
|
|
|
loaderLength = parseInt(loaderLengthArg)
|
|
|
|
logEarly()
|
|
|
|
}
|
2016-06-10 03:59:21 +00:00
|
|
|
|
2016-08-20 05:41:56 +00:00
|
|
|
process.on('SIGINT', () => {
|
2016-09-18 21:11:26 +00:00
|
|
|
logEarlyAbort = true
|
|
|
|
})
|
|
|
|
|
|
|
|
start()
|