2016年(48)
分类: JavaScript
2016-10-27 17:51:52
Portable Unix shell commands for Node.js
ShellJS is a portable (Windows/Linux/OS X) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts!
ShellJS supports node v0.11, v0.12, v4, v5, v6, and all releases of iojs.
The project is and battled-tested in projects like:
If you have feedback, suggestions, or need help, feel free to post in our .
Think ShellJS is cool? Check out some related projects (like --a javascript-based POSIX shell) in our !
Upgrading from an older version? Check out our page to see what changes to watch out for while upgrading.
If you just want cross platform UNIX commands, checkout our new project , a utility to expose shelljs to the command line.
For example:
点击(此处)折叠或打开
For documentation on all the latest features, check out our . To read docs that are consistent with the latest release, check out or shelljs.org.
Via npm:
点击(此处)折叠或打开
If the global option -g is specified, the binary shjs will be installed. This makes it possible to run ShellJS scripts much like any shell script from the command line, i.e. without requiring a node_modules folder:
点击(此处)折叠或打开
点击(此处)折叠或打开
CoffeeScript is also supported automatically:
点击(此处)折叠或打开
The example above uses the convenience script shelljs/global to reduce verbosity. If polluting your global namespace is not desirable, simply requireshelljs.
Example:
点击(此处)折叠或打开
All commands run synchronously, unless otherwise stated. All commands accept standard bash globbing characters (*, ?, etc.), compatible with the.
For less-commonly used commands and features, please check out our .
Changes to directory dir for the duration of the script. Changes to home directory if no argument is supplied.
Returns the current directory.
Available options:
Examples:
点击(此处)折叠或打开
Returns array of files in the given path, or in current directory if no path provided.
Examples:
点击(此处)折叠或打开
Returns array of all files (however deep) in the given paths.
The main difference from ls('-R', path) is that the resulting file names include the base directories, e.g. lib/resources/file1 instead of just file1.
Available options:
Examples:
点击(此处)折叠或打开
Copies files.
Available options:
Examples:
点击(此处)折叠或打开
Removes files.
Available options:
Examples:
点击(此处)折叠或打开
Moves files.
Available options:
Examples:
点击(此处)折叠或打开
Creates directories.
Available expression primaries:
Examples:
点击(此处)折叠或打开
wemall 开源微商城 ,微信商城,商城源码,三级分销,微生鲜,微水果,微外卖,微订餐---专业的o2o系统
wemall地址: