@stdlib/process-chdir
v0.2.1
Published
Change the current working directory.
Downloads
5
Readme
chdir
Change the current working directory.
Installation
npm install @stdlib/process-chdir
Usage
var chdir = require( '@stdlib/process-chdir' );
chdir( path )
Changes the current working directory to the specified path
.
var err = chdir( '/foo/bar' );
If the function encounters an error when attempting to change the working directory, the function returns an error
; otherwise, the function returns null
.
Notes
- See chdir(2).
Examples
var cwd = require( '@stdlib/process-cwd' );
var chdir = require( '@stdlib/process-chdir' );
// Print the current working directory:
var dir = cwd();
console.log( dir );
// Change the current working directory to the directory of this file:
var err = chdir( __dirname );
if ( err ) {
console.error( err.message );
}
// Print the current working directory:
console.log( cwd() );
// Change the current working directory back to the original directory:
err = chdir( dir );
if ( err ) {
console.error( err.message );
}
// Print the current working directory:
console.log( cwd() );
See Also
@stdlib/process-cwd
: return the current working directory.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.