Permalink
Browse files

Merge branch 'release/0.2.0'

  • Loading branch information...
2 parents e45f467 + bf2a2f9 commit 6e89792e18cc0607b56b1f1200c5ad5d6a762222 @aponxi committed Mar 3, 2013
View
@@ -10,51 +10,38 @@ module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
- # Before generating any new files, remove any previously-created files.
- clean:
- tests: ["tmp"]
-
# Configuration to be run (and then tested).
wxi_shell:
- one:
+ make:
options:
cwd: 'components/bootstrap'
+ returnOutput: on
+ chained: on
+ exitSuccess: [0,2]
commands:
- "[Bootstrap] First stage: make": "info"
- "make" : "run"
- "[Bootstrap] First stage done: make" : "ok"
- "[Bootstrap] Second stage: make bootstrap": "info"
- "make bootstrap" : "run"
- "[Bootstrap] Second stage done: make bootstrap" : "ok"
- "[Bootstrap] Done making!" : "ok"
- two:
+ [
+ "make"
+ ,
+ "make bootstrap"
+ ]
+ clean:
options:
cwd: 'components/bootstrap'
+ returnOutput: on
+ chained: on
+ exitSuccess: [0, 2]
commands:
- "[Second Test] First stage: make": "info"
- "make" : "err"
- "[Second Test] First stage done: make" : "ok"
- "[Second Test] Second stage: make bootstrap": "info"
- "make bootstrap" : "err"
- "[Second Test] Second stage done: make bootstrap" : "ok"
- "[Second Test] Done making!" : "ok"
- # Unit tests.
- nodeunit:
- tests: ["test/*_test.js"]
-
+ [
+ "make clean"
+ ]
# Actually load this plugin's task(s).
grunt.loadTasks "tasks"
- # These plugins provide necessary tasks.
- grunt.loadNpmTasks "grunt-contrib-jshint"
- grunt.loadNpmTasks "grunt-contrib-clean"
- grunt.loadNpmTasks "grunt-contrib-nodeunit"
-
- # Whenever the "test" task is run, first clean the "tmp" dir, then run this
# plugin's task(s), then test the result.
- grunt.registerTask "test", ["clean","wxi_shell"]
-
- # By default, lint and run all tests.
+
+ grunt.registerTask "clean", ["wxi_shell:clean"]
+ grunt.registerTask "test", ["clean", "wxi_shell:make"]
+ # By default
grunt.registerTask "default", ["test"]
View
@@ -1,106 +1,192 @@
# grunt-wxi-shell
-> Executing Shell commands with grunt.
+> Executing Shell commands synchronously with grunt.
## Getting Started
-_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._
+This plugin requires Grunt `~0.4.0`
-From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:
+If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
-```bash
+```shell
npm install grunt-wxi-shell --save-dev
```
-Once that's done, add this line to your project's Gruntfile:
+Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-wxi-shell');
```
-If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.
+*This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4).
-[grunt]: http://gruntjs.com/
-[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
-[package.json]: https://npmjs.org/doc/json.html
-## The "wxi_shell" task
-
-### Overview
+## Overview
In your project's Gruntfile, add a section named `wxi_shell` to the data object passed into `grunt.initConfig()`.
```coffeescript
+ # this is coffeescript
wxi_shell:
one:
options:
cwd: 'components/bootstrap'
+ returnOutput: true
+ chained: true
+ exitSuccess: [0,2]
commands:
- "[Bootstrap] First stage: make": "info"
- "make" : "err"
- "[Bootstrap] First stage done: make" : "ok"
- "[Bootstrap] Second stage: make bootstrap": "info"
- "make bootstrap" : "err"
- "[Bootstrap] Second stage done: make bootstrap" : "ok"
- "[Bootstrap] Done making!" : "ok"
- two:
- options:
- cwd: 'components/bootstrap'
- commands:
- "[Second Test] First stage: make": "info"
- "make" : "err"
- "[Second Test] First stage done: make" : "ok"
- "[Second Test] Second stage: make bootstrap": "info"
- "make bootstrap" : "err"
- "[Second Test] Second stage done: make bootstrap" : "ok"
- "[Second Test] Done making!" : "ok"
+ [
+ "make"
+ ,
+ "make bootstrap"
+ ]
+
```
-### Options
+Or JavaScript:
-#### options.cwd
-Type: `String`
-Default value: `null`
+```js
-The working directory, runs commands in that directory.
+ wxi_shell: {
+ one: {
+ options: {
+ cwd: 'components/bootstrap',
+ returnOutput: true,
+ chained: true,
+ exitSuccess: [0, 2]
+ },
+ commands: ["make", "make bootstrap"]
+ }
+ }
+
+};
+```
-### Usage Examples
+## Options
-#### Let's say you wanted to build bootstrap
-If you specify cwd then the commands are run as `cd "your/directory" && ls` if you dont' then they are run in the project root.
+- `cwd`: `string`
-The syntax for commands are like this:
+ `cwd`, is where a command should be run. Default is the project root (where Gruntfile is present). This works by putting `cd foo/bar && ` before the command to be run.
-`"Command or text" : "type"`
+### These options are from execxi
-If you want to execute a command then type is `run`, if you want to send a message to the terminal then you have three choices:
+You can check out the project at [aponxi/npm-execxi](https://github.com/aponxi/npm-execxi).
-- `ok` - green message with a tick
-- `info` - blue message with a square bullet
-- `err` - red message with a triangle
+- `chained`: `bool`
-These messages are automatically formatted and echoed.
+ `chained`, which is `true` by default, is an option that can stop running commands after one of them failed. To see if it failed, it checks the exit code of the command that is run.
+- `returnOutput`: `bool`
-```js
+ `returnOutput` is also `true` by default. This is what returns the output in an array, parsing them line by line. I supply with this option because sometimes you might run a command that only returns server's IP address or sometimes you can run a command that just outputs very long lines and a very long text. I added the ability to opt out so that when unnecessary you might set it to false.
+
+- `exitSuccess`: `Array(int[,int, ...])`
+
+ `exitSuccess` is an array that contains a collection of error codes that you deem to be a successful exit. All programs use different exit codes, sometimes they give a warning and exit with `2`. In situations like those, I find myself wanting to allow exiting with `2` for that group of commands to be treated as if command was successfully run. This allows the chained commands to continue.
+
+ By default only `0` exit codes are known to be successful runs. If you supply with `exitSuccess` option you will be overriding that. So, by your definition; a program that fails to run can still be a success.
+
+- `prettyPrint`: `bool`
+
+ `prettyPrint` is `true` by default. This gives the console output its color. Sometimes I find that I need to redirect output into a log file, and don't want the ANSI escape characters such as `\033[0;32m` to appear in the log. This will give you a colorless output in console messages.
+
+- `verbose`: `bool`
+
+ `verbose` is `true` by default. It is used for outputting the command's output as well as giving information on the status (such as "Running Command [1/3]"). There may be times when you just want to quietly utilize the shell command's output. Setting this to `false` will save you from headaches. I usually turn it off when I'm conducting tests, because if I don't, it's a real mess.
+
+### Usage Examples
+
+#### Let's say you wanted to build bootstrap
+If you specify cwd then the commands are run as `cd "your/directory" && ls` if you dont' then they are run in the project root.
+
+CoffeeScript:
+
+```coffeescript
+"use strict"
+module.exports = (grunt) ->
+
+ # Project configuration.
+ grunt.initConfig
+
+ # Configuration to be run (and then tested).
wxi_shell:
- bootstrap:
+ make:
options:
cwd: 'components/bootstrap'
+ returnOutput: on
+ chained: on
+ exitSuccess: [0,2]
commands:
- "[Bootstrap] First stage: make": "info"
- "make" : "run"
- "[Bootstrap] First stage done: make" : "ok"
- "[Bootstrap] Second stage: make bootstrap": "info"
- "make bootstrap" : "run"
- "[Bootstrap] Second stage done: make bootstrap" : "ok"
- "[Bootstrap] Done making! But we have never thrown an error!" : "err"
+ [
+ "make"
+ ,
+ "make bootstrap"
+ ]
+ clean:
+ options:
+ cwd: 'components/bootstrap'
+ returnOutput: on
+ chained: on
+ exitSuccess: [0, 2]
+ commands:
+ [
+ "make clean"
+ ]
+
+ # Actually load this plugin's task(s).
+ grunt.loadTasks "tasks"
+
+ # plugin's task(s), then test the result.
+
+ grunt.registerTask "clean", ["wxi_shell:clean"]
+ grunt.registerTask "test", ["clean", "wxi_shell:make"]
+ # By default
+ grunt.registerTask "default", ["test"]
```
+Or Javascript:
+
+```js
+"use strict";
+
+module.exports = function(grunt) {
+ grunt.initConfig({
+ wxi_shell: {
+ make: {
+ options: {
+ cwd: 'components/bootstrap',
+ returnOutput: true,
+ chained: true,
+ exitSuccess: [0, 2]
+ },
+ commands: ["make", "make bootstrap"]
+ },
+ clean: {
+ options: {
+ cwd: 'components/bootstrap',
+ returnOutput: true,
+ chained: true,
+ exitSuccess: [0, 2]
+ },
+ commands: ["make clean"]
+ }
+ }
+ });
+ grunt.loadTasks("tasks");
+ grunt.registerTask("clean", ["wxi_shell:clean"]);
+ grunt.registerTask("test", ["clean", "wxi_shell:make"]);
+ return grunt.registerTask("default", ["test"]);
+};
+
+```
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt][].
## Release History
+### v0.2.0 - ExecXI
+
+- Changed the way commands are executed by using [aponxi/npm-execxi](https://github.com/aponxi/npm-execxi)
+- Tested, and it works.
### v0.1.7 - Tests
- Added bootstrap as component to test tasks on it
Oops, something went wrong.

0 comments on commit 6e89792

Please sign in to comment.