shellasync
v2.1.0
Published
asynchronous shell-like commands using Node.js fs API
Downloads
10
Maintainers
Readme
shellasync
Asynchronous shell-like functions using Node.js fs API
Usage:
require('shellasync/global');
All commands are async and take an optional callback in the last argument. If omitted, the default callback will log the results to the console (useful for interactive usage). Available commands:
cat(paths[, cb])
: read files usingfs.readFile()
as text, concatenate together in orderreadlink(path[, cb])
: read symbolic link target usingfs.readlink()
chmod(path, mode[, cb])
: change file mode permission usingfs.chmod()
chown(path, uid, gid[, cb])
: change file ownership permission usingfs.chown()
pwd()
: returns the current value ofprocess.env.PWD
cd([path, [, cb]])
: sets theprocess.env.PWD
working directory variable topath
if it exists, orprocess.env.HOME
if undefinedls(path[, cb])
: list directory contents usingfs.readdir()
mv(oldPath, newPath[, cb])
: rename file usingfs.rename()
rmdir(path[, cb])
: remove directory usingfs.rmdir()
mkdir(path[, mode][, cb])
: create a directory usingfs.mkdir()
stat(path[, cb])
: read file statistics usingfs.lstat()
ln(path, target[, cb)
: create a symbolic link usingfs.symlink()
rm(path[, cb])
: remove a file usingfs.unlink()
All paths can either be absolute if starting with '/', or are otherwise relative to
process.env.PWD
. The process working directory (as set by process.chdir()
) is not
used by this module, only process.env.PWD
.
By default, the global object is extended, for convenience. Alternatively, each command can be accessed on the shellasync object instead:
var shell = require('shellasync');
shell.cat(path, cb); // etc.
See also: shelljs - Portable Unix shell commands for Node.js.
shellasync is inspired by shelljs and the feature request
https://github.com/shelljs/shelljs/issues/2 Async versions of all commands,
but is much more primitive and has a different target use case. Instead of writing
JavaScript replacements for shell script commands, shellasync was written for
mostly-interactive console user interaction with the shell via the asynchronous fs
API,
including non-native Node.js implementations of fs
(e.g. web-based, remote, etc.).
License
MIT