Skip to content

Commit

Permalink
Add binPath parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ZAYEC77 committed Jun 5, 2016
1 parent 1e8a8e0 commit 49c7fba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,33 @@ gulp.task('test', function () {
.pipe(casperJs()); //run casperjs test
});
```

To change the command (default: `test`) use parameter `command`:

```js
var casperJs = require('gulp-casperjs');
gulp.task('casperCmd', function () {
gulp.src('test.js')
.pipe(casperJs({command:''})); //run casperjs test.js
});
```

Command can be `array` or `string`.
If command has value which cast to `false`, this parameter will be ignored.

To hide output from CasperJS use parameter `outputLog`:
To set custom path to CasperJS use parameter `binPath`:

```js
var casperJs = require('gulp-casperjs');
gulp.task('casperCmd', function () {
gulp.task('test', function () {
gulp.src('test.js')
.pipe(casperJs({outputLog: false})); //CasperJS output not show
.pipe(casperJs({binPath: './node_modules/casperjs/bin/casperjs'})); //custom path to CasperJs
});
```
Default value is `true`

Default is `casperjs` (global)


## LICENSE

The MIT License (MIT)
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function casper(options) {

var cmd = (typeof options.command === 'undefined') ? 'test' : options.command;

var outputLog = (typeof options.outputLog === 'boolean') ? options.outputLog : true;
var binPath = (typeof options.binPath === 'undefined') ? 'casperjs' : options.binPath;

var files = [];

Expand All @@ -37,14 +37,12 @@ function casper(options) {
var end = function(cb) {
cmd = cmd ? (Array.isArray(cmd) ? cmd : cmd.split(' ')) : [];

var casperChild = spawn('casperjs', cmd.concat(files));
var casperChild = spawn(binPath, cmd.concat(files));

if (outputLog)
casperChild.stdout.on('data', function(data) {
var msg = data.toString().slice(0, -1);
gutil.log(PLUGIN_NAME + ':', msg);
});
}
casperChild.stdout.on('data', function(data) {
var msg = data.toString().slice(0, -1);
gutil.log(PLUGIN_NAME + ':', msg);
});

var self = this;
casperChild.on('close', function(code) {
Expand Down

0 comments on commit 49c7fba

Please sign in to comment.