TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published


A zero-dependency collection of utility functions to simplify the writing of typical „bash-like“ (or rather: bash-replacing) NodeJS scripts for your local machine (respectively: server-side scripting).

Originally written for a series of barejs setup scripts, for a full range of „secondary system setup“ on fresh Ubuntu-MATE machines. Now also used in my photo organizing cli commands.

  • dependency-free
  • all NodeJS, all ES6
  • no Common JS, no Typescript, no transpilation
  • async as much as possible
  • strong emphasis on fast-fail behaviour (plenty of asserts, called „ensure“)

Areas covered:

  • Logging: Well, not too far apart from console.log|warn.error() but with a few twists on serialization and dumping of objects. Output coloring included, too.
  • Asserts: All kinds of useful asserts. Not meant for testing but for easier, better fast-fail-behaviour and clearer error reporting at runtime
  • Executions: Execution of binaries aka linux commands. Yes, at its heart this is no more than NodeJS' usual execSync, but with some convenience on stdout, returned strings and error codes and assertion, if desired
  • FileUtils: write complete files with a single command, rsync directories, be more cautious on ensuring paths are user-intended, quickly check files on the existence of snippets...
  • GitUtils: Well, so far there's just one wrapper to obtain (and usually verify) git properties
  • DconfUtils: Writing registry data to Linux dconf registry was vital to me for system setup scripts (and is trickier than you might think)
  • ioUtils: Reading one line of input in NodeJS sadly requires a few more lines of NodeJS source code... here they are.


npm install -S @nocke/util


This is an ES6 module, thus all import, no require().

No submodules, everything is directly importable, resp. available in the module's default export:

import util from '@nocke/util'
util.info(`hello`, ...)


import { purple, info, warn } from '@nocke/util'
info(`hello`, ...)

I somehow favor the latter for simplicity in the actual code.

nb: there is actually a test to ensure, I did not forget an export on either side (singular or grouped export aka „default“) side.


npm run create-types

creates/updates typescript types (.d.ts) for the library. While these are rather unspecific (this is not a typescript library, not requiring transpilation…), this is picked up by many IDEs, facilitating auto completion.

Package Sidebar


npm i @nocke/util

Weekly Downloads






Unpacked Size

49.6 kB

Total Files


Last publish


  • nocke