in-folder

v1.0.3
Temporarily change directories to run a callback
cwd folder process micropackage change directory dir

in-folder (a micropackage)

Temporarily change directories to run a callback

NPM Version Linux Build Windows Build Test Coverage

Installation

npm install in-folder

Usage

let inside = require('in-folder')

let showFolder = () => console.log("Folder: " + process.pwd())

showFolder()
inside("lib", showFolder)
showFolder()

If the current working directory was '/var', and '/var/lib' existed, then the output would be:

Folder: /var
Folder: /var/lib
Folder: /var

Notes

  • Promises, if returned within the callback, will be resolved and returned by in-folder.
  • Supports relative and absolute paths
  • Uses process.chdir to change folders

License

MIT

npm i in-folder

Metadata

  • MIT
  • >= 7.7.2
  • David MacDonald
  • released 3/12/2017

Downloads

Maintainers