shutil.jsx

0.1.1 • Public • Published

shutil.jsx

Synopsis

High level file/directory operation methods. It is inspired by Python's shutil module.

Installation

$ npm install shutil.jsx --save-dev

API Reference

shutil.walk(path, callback: (string, string[], string[]) -> void) : void

Traverse directory and returns contents.

import "shutil.jsx";
 
class _Main {
    static function main(argv : string[]) : void
    {
        shutil.walk("/Users/home/myname", (root, dirs, files) -> {
            console.log(root);
            console.log("  dirs in this folder: " + dirs.join(""));
            console.log("  files in this folder: " + irs.join(""));
        });
    }
}

shutil.mkdirp(directory : string) : boolean

Create a new directory and any necessary subdirectories.

import "shutil.jsx";
 
class _Main {
    static function main(argv : string[]) : void
    {
        shutil.mkdirp("/you/can/create/deep/directories/at/the/same/time");
    }
}

shutil.copyFile(inputPath : string, outputPath : string) : boolean

Copy existing file.

import "shutil.jsx";
 
class _Main {
    static function main(argv : string[]) : void
    {
        // back up important file!
        shutil.copy("/Users/myname/.vimrc", "/Users/myname/Dropbox/.vimrc");
    }
}

shutil.splitPath(path : string) : string[]

Split path entries and return string array.

import "shutil.jsx";
import "console.jsx";
 
class _Main {
    static function main(argv : string[]) : void
    {
        // back up important file!
        console.log(shutil.splitPath("/Users/myname/.vimrc"));
        // -> '/', Users, myname, .vimrc
    }
}

shutil.rmtree(path : string) : void

Remove directory including children folders and files.

import "shutil.jsx";
 
class _Main {
    static function main(argv : string[]) : void
    {
        // clear cache
        shutil.rmtree("/Users/myname/.npm/");
    }
}

Development

Repository

Run Test

$ grunt test

Build Sample

$ grunt build

Generate API reference

$ grunt doc

Author

License

The MIT License (MIT)

Complete license is written in LICENSE.md.

Readme

Keywords

Package Sidebar

Install

npm i shutil.jsx

Weekly Downloads

0

Version

0.1.1

License

The MIT License (MIT)

Last publish

Collaborators

  • shibu