a1-util
v2.1.0
Published
General usage functions library. The aim of the library is to keep as small as possible but avoid the user link a ton of one-line function modules dependency.
Downloads
5
Readme
a1-util
Set of handy, specialized functions, to avoid repeating tasks but also to avoid having a ton of tiny one-line separate modules.
The library is intended to be kept as small as possible for ever. This is not a generic utilities library. Pick a popular one for those tasks.
API
See util.js for in-depth documentation
execute(command, options?): execute a command like as in the terminal but 1-returns promise and 2-stderr is treated as exception (and therefore, thrown). If the command is detached (
./myProcess &
), the execution runs in parallel but the stdio pipes are the same as the app. This is useful when the app is running as a service, and logs int the secondary app are automatically logged in the parent app. Also, if the parent app is stopped, the detached processes will also be stopped (no orphane processes). Options, only for advanced (or future) features.unref = true
when the process will start as completely separated process with its own stdio and it will keep running even if the parent process stops.sleep(millis): non-blocking delay in milliseconds.
dirname(): ESM alternative to _dirname. It also works on bundled files.
log(type, message): pretty-print logs with a unicode colored symbol as prefix. Types ['ok', 'error'].