Skip to content

Commit

Permalink
Lots of work on passing config options and refactoring. See conversat…
Browse files Browse the repository at this point in the history
…ion in #3.
  • Loading branch information
Jackson Gariety committed Jan 12, 2014
1 parent 64d80a8 commit 4fe7d5c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
npm-debug.log
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@ A gulp task that will re-load your node script when it changes. Perfect for deve

## Usage

### **`nodemon()`**
### **`nodemon([settings])`**

`nodemon()` returns a stream for use in a streaming system like [gulp.js](http://gulpjs.com).
You can pass an object to gulp nodemon with two optional settings:

```javascript
{
args: '-e html,js -i foo.js'
, crash: function (stream) {
//
}
, exit:
, restart:
}
```

Watch `.html` and `.js` files, but don't watch `foo.js`.

It returns a stream for use in a streaming system like [gulp.js](http://gulpjs.com).

## Example

Expand All @@ -22,6 +37,6 @@ var gulp = require('gulp')
gulp.task('develop', function () {
gulp.src('./server.js')
.pipe(jshint())
.pipe(nodemon())
.pipe(nodemon('-e html,js -i foo.js'))
})
```
21 changes: 12 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
var map = require('map-stream')
var es = require('event-stream')
, nodemon = require('nodemon')
, cli = require('nodemon/lib/cli')
, path = require('path')

module.exports = function (settings) {
return map(function (file, callback) {
settings = settings || ''

return es.map(function (file, callback) {
var options = ['nodemon', path.resolve(file.path)].concat(settings.split(' '))

try {
// Our script
nodemon({
script: file.path
, args: []
, restartable: 'rs'
})

// Forward ^C to gulp
options = cli.parse(options)
options.restartable = 'rs'
nodemon({ script: file.path, args: [], restartable: 'fs' })
// Forward ^C back to gulp
process.on('SIGINT', function () { process.exit() })
} catch (e) { throw e }

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-nodemon",
"version": "0.0.3",
"version": "0.0.4",
"description": "A gulp task that will reload your node script when it changes.",
"main": "index.js",
"scripts": {
Expand All @@ -27,8 +27,8 @@
},
"homepage": "https://github.com/JacksonGariety/gulp-nodemon",
"dependencies": {
"map-stream": "0.0.4",
"nodemon": "~1.0.1"
"nodemon": "~1.0.1",
"event-stream": "~3.0.20"
},
"devDependencies": {
"gulp": "~3.2.2",
Expand Down

0 comments on commit 4fe7d5c

Please sign in to comment.