Fetching metadata
Reading directory listings, fetching permissions, and getting the time creation and modification. These are all essential pieces of the filesystem tool kit.
Note
Most of the fs
and POSIXfs
module methods are light wrappers around POSIX operations (with shims for Windows), so many of the concepts and names should be similar if we've indulged in any system programming or even shell scripting.
In this recipe, we're going to write a CLI tool that supplies in-depth information files and directories for a given path.
Getting ready
To get started, let's create a new folder called fetching-meta-data
, containing a file called meta.js
:
$ mkdir fetching-meta-data $ cd fetching-meta-data $ touch meta.js
Now let's use npm
to create package.json
file:
$ npm init -y
We're going to display tabulated and styled metadata in the terminal; instead of manually writing ANSI codes and tabulating code, we'll simply be using the third-party tableaux
module.
We can install it like so:
$ npm install --save...