An implementation of pushd/popd for JavaScript.


License
MIT
Install
npm install util.chdir@0.0.40

Documentation

util.chdir

An implementation of pushd/popd for JavaScript

build analysis code style: prettier testing NPM

This mimics the bash pushd/popd functions. When changing a directory the pushd will place the current directory onto a stack and then change to the requested directory. When popd is called, then the previous directory is restored from the top of that stack. This is a way to simplify backtracking through a directory hierarchy.

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as a global package and cli:

$ yarn global add util.chdir

To install as a development dependency with cli:

$ yarn add --dev util.chdir

To build the app and run all tests:

$ yarn run all

Usage

const chdir = require('util.chdir');

// assume directory is /home
chdir.pushd('/tmp');
// pushes /home on the stack and changes to /tmp

chdir.popd();
// pops the top of the stack and switches to that directory