Prefix to a CLI command to print out the time taken.
npm install @choksheak/timecli
npm i -D @choksheak/timecli
`
Why do you need this?
I searched around (Dec 2020) and was unable to find any npm package that serves the same purpose. The closest match is gnomon, but the output is too heavy and it loses all console colors from the original output.
Some reasons why you want to install this package:
1. Cross-platform portability - no need to worry about using platform-specific timer executables.
2. Tiny in size - There are a few minimally-needed dependencies, but they are also tiny.
3. Uses pure Node + Javascript only - no need to deal with potential antivirus warnings from running .exe files.
4. Fast - takes 0.1 seconds or less to run.
5. Simple - Outputs a one-liner at the end of the run, showing the time clearly.
6. Convenient - Able to run any command from your PATH environment variable or in your local node_modules/.bin directory.
7. Non-intrusive - Just prepend any command with timecli in your package.json to time the task everytime you run it!
8. Fun! - console output is colored!
Usage
`sh
> npx timecli
[timecli] Usage: npx timecli [command] ...
`
Examples
$3
`sh
> npx timecli node test.js
[test.js] Test script: Yellow Cyan Green Red
[timecli] Took 0.082s. [Exit code = 0]
`
$3
`sh
> npx timecli sleep 10
[timecli] Took 10.688s. [Exit code = 0]
`
$3
`sh
> npx timecli sleep 70
[timecli] Took 1m 12s (72.517s). [Exit code = 0]
``