shutil.jsx
v0.1.1
Published
High level file/directory operation methods.
Downloads
2
Readme
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
- Repository: git://github.com/shibukawa/shutil.jsx.git
- Issues: https://github.com/shibukawa/shutil.jsx/issues
Run Test
$ grunt test
Build Sample
$ grunt build
Generate API reference
$ grunt doc
Author
- shibukawa / [email protected]
License
The MIT License (MIT)
Complete license is written in LICENSE.md
.