in-folder

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i in-folder

Weekly Downloads

48

Version

1.0.3

License

MIT

Last publish

Collaborators

  • mindlapse