Nectar of the Programming Masses

    @stdlib/process-chdir
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.6 • Public • Published

    chdir

    NPM version Build Status Coverage Status dependencies

    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

    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() );

    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

    Chat


    License

    See LICENSE.

    Copyright

    Copyright © 2016-2021. The Stdlib Authors.

    Install

    npm i @stdlib/process-chdir

    Homepage

    stdlib.io

    DownloadsWeekly Downloads

    18

    Version

    0.0.6

    License

    Apache-2.0

    Unpacked Size

    36 kB

    Total Files

    10

    Last publish

    Collaborators

    • stdlib-bot
    • kgryte
    • planeshifter
    • rreusser