2016-09-15 12:45:58 +00:00
|
|
|
import 'typings-global'
|
|
|
|
import chalk = require('chalk')
|
|
|
|
import q = require('q')
|
2016-06-10 03:18:03 +00:00
|
|
|
|
2016-09-15 12:45:58 +00:00
|
|
|
let doText: boolean = false
|
|
|
|
let moduleName: string = 'undefined module name'
|
2016-09-18 22:34:38 +00:00
|
|
|
let startTime = Date.now()
|
2016-08-20 05:03:49 +00:00
|
|
|
|
2016-09-18 22:34:38 +00:00
|
|
|
if (process.argv.indexOf('-v') === -1) {
|
2016-09-15 12:45:58 +00:00
|
|
|
doText = true
|
2016-06-10 03:18:03 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 22:34:38 +00:00
|
|
|
/**
|
|
|
|
* start the loading
|
|
|
|
*/
|
2016-09-15 12:45:58 +00:00
|
|
|
export let start = function (moduleNameArg: string = '', loaderLengthArg: string = '10') {
|
|
|
|
moduleName = moduleNameArg
|
2016-09-18 22:34:38 +00:00
|
|
|
if (doText) {
|
2016-09-15 12:45:58 +00:00
|
|
|
console.log(`**** starting ${chalk.green(moduleNameArg)} ****`)
|
2016-06-10 03:18:03 +00:00
|
|
|
}
|
2016-09-15 12:45:58 +00:00
|
|
|
}
|
2016-05-20 17:06:25 +00:00
|
|
|
|
2016-09-15 12:59:22 +00:00
|
|
|
export let stop = (): q.Promise<number> => {
|
|
|
|
let done = q.defer<number>()
|
2016-09-15 12:45:58 +00:00
|
|
|
let endTime = Date.now()
|
2016-09-15 12:59:22 +00:00
|
|
|
let earlyExecutionTime: number = (endTime - startTime)
|
|
|
|
let earlyExecutionTimeString: string = (earlyExecutionTime / 1000).toString()
|
2016-09-18 22:34:38 +00:00
|
|
|
console.log(`... finished loading ${moduleName} in ${earlyExecutionTimeString}`)
|
|
|
|
done.resolve(earlyExecutionTime)
|
2016-09-15 12:45:58 +00:00
|
|
|
return done.promise
|
|
|
|
}
|