{"id":14982093,"url":"https://github.com/colemangariety/gulp-nodemon","last_synced_at":"2025-04-04T16:15:56.237Z","repository":{"id":12963467,"uuid":"15641862","full_name":"ColemanGariety/gulp-nodemon","owner":"ColemanGariety","description":"gulp + nodemon + convenience","archived":false,"fork":false,"pushed_at":"2022-12-05T11:39:21.000Z","size":538,"stargazers_count":525,"open_issues_count":46,"forks_count":76,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-28T15:08:33.065Z","etag":null,"topics":["bunyan","gulp","gulp-tasks","lint","nodemon"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ColemanGariety.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-04T23:52:23.000Z","updated_at":"2025-02-03T19:29:28.000Z","dependencies_parsed_at":"2023-01-13T17:13:42.600Z","dependency_job_id":null,"html_url":"https://github.com/ColemanGariety/gulp-nodemon","commit_stats":null,"previous_names":["colemangariety/gulp-nodemon","jacksongariety/gulp-nodemon"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColemanGariety%2Fgulp-nodemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColemanGariety%2Fgulp-nodemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColemanGariety%2Fgulp-nodemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColemanGariety%2Fgulp-nodemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ColemanGariety","download_url":"https://codeload.github.com/ColemanGariety/gulp-nodemon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208181,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bunyan","gulp","gulp-tasks","lint","nodemon"],"created_at":"2024-09-24T14:04:46.590Z","updated_at":"2025-04-04T16:15:56.217Z","avatar_url":"https://github.com/ColemanGariety.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"gulp-nodemon\n===========\n\ngulp + nodemon + convenience\n\n## Install\n\n```bash\n$ npm install --save-dev gulp-nodemon\n```\n\n## Usage\n\nGulp-nodemon is almost exactly like regular nodemon, but it's made for use with gulp tasks.\n\n### **nodemon([options])**\n\nGulp-nodemon takes an options object [just like the original](https://github.com/remy/nodemon#config-files).\n\nExample below will start `server.js` in `development` mode and watch for changes, as well as watch all `.html` and `.js` files in the directory.\n```js\ngulp.task('start', function (done) {\n  nodemon({\n    script: 'server.js'\n  , ext: 'js html'\n  , env: { 'NODE_ENV': 'development' }\n  , done: done\n  })\n})\n```\n\n## Synchronous Build Tasks\n\n*NOTE: This feature requires Node v0.12 because of `child_process.spawnSync`.*\n\nGulp-nodemon can synchronously perform build tasks on restart.\n\n### **{ tasks: [Array || Function(changedFiles)] }**\n\nIf you want to lint your code when you make changes that's easy to do with a simple event. But what if you need to wait while your project re-builds before you start it up again? This isn't possible with vanilla nodemon, and can be tedious to implement yourself, but it's easy with gulp-nodemon:\n```js\nnodemon({\n  script: 'index.js'\n, tasks: ['browserify']\n})\n```\n\nWhat if you want to decouple your build processes by language? Or even by file? Easy, just set the `tasks` option to a function. Gulp-nodemon will pass you the list of changed files and it'll let you return a list of tasks you want run.\n\n*NOTE:* If you manually restart the server (`rs`) this function will receive a `changedFiles === undefined` so check it and return the `tasks` because it expects an array to be returned.\n\n```js\nnodemon({\n  script: './index.js'\n, ext: 'js css'\n, tasks: function (changedFiles) {\n    var tasks = []\n    if (!changedFiles) return tasks;\n    changedFiles.forEach(function (file) {\n      if (path.extname(file) === '.js' \u0026\u0026 !~tasks.indexOf('lint')) tasks.push('lint')\n      if (path.extname(file) === '.css' \u0026\u0026 !~tasks.indexOf('cssmin')) tasks.push('cssmin')\n    })\n    return tasks\n  }\n})\n```\n\n## Events\n\ngulp-nodemon returns a stream just like any other NodeJS stream, **except for the `on` method**, which conveniently accepts gulp task names in addition to the typical function.\n\n### **.on([event], [Array || Function])**\n\n1. `[event]` is an event name as a string. See [nodemon events](https://github.com/remy/nodemon/blob/master/doc/events.md).\n2. `[tasks]` An array of gulp task names or a function to execute.\n\n### **.emit([event])**\n1. `event`   is an event name as a string. See [nodemon events](https://github.com/remy/nodemon/blob/master/doc/events.md#using-nodemon-events).\n\n## Examples\n\n### Basic Usage\n\nThe following example will run your code with nodemon, lint it when you make changes, and log a message when nodemon runs it again.\n\n```js\n// Gulpfile.js\nvar gulp = require('gulp')\n  , nodemon = require('gulp-nodemon')\n  , jshint = require('gulp-jshint')\n\ngulp.task('lint', function () {\n  gulp.src('./**/*.js')\n    .pipe(jshint())\n})\n\ngulp.task('develop', function (done) {\n  var stream = nodemon({ script: 'server.js'\n          , ext: 'html js'\n          , ignore: ['ignored.js']\n          , tasks: ['lint'] })\n          , done: done\n\n  stream\n      .on('restart', function () {\n        console.log('restarted!')\n      })\n      .on('crash', function() {\n        console.error('Application has crashed!\\n')\n         stream.emit('restart', 10)  // restart the server in 10 seconds\n      })\n})\n```\n\n_**You can also plug an external version or fork of nodemon**_\n```js\ngulp.task('pluggable', function() {\n  nodemon({ nodemon: require('nodemon'),\n            script: 'server.js'})\n})\n```\n\n### Bunyan Logger integration\n\nThe [bunyan](https://github.com/trentm/node-bunyan/) logger includes a `bunyan` script that beautifies JSON logging when piped to it. Here's how you can you can pipe your output to `bunyan` when using `gulp-nodemon`:\n\n```js\ngulp.task('run', ['default', 'watch'], function(done) {\n    var nodemon = require('gulp-nodemon'),\n        spawn   = require('child_process').spawn,\n        bunyan\n\n    nodemon({\n        script: paths.server,\n        ext:    'js json',\n        ignore: [\n            'var/',\n            'node_modules/'\n        ],\n        watch:    [paths.etc, paths.src],\n        stdout:   false,\n        readable: false,\n        done: done\n    })\n    .on('readable', function() {\n\n        // free memory\n        bunyan \u0026\u0026 bunyan.kill()\n\n        bunyan = spawn('./node_modules/bunyan/bin/bunyan', [\n            '--output', 'short',\n            '--color'\n        ])\n\n        bunyan.stdout.pipe(process.stdout)\n        bunyan.stderr.pipe(process.stderr)\n\n        this.stdout.pipe(bunyan.stdin)\n        this.stderr.pipe(bunyan.stdin)\n    });\n})\n```\n\n## Using `gulp-nodemon` with React, Browserify, Babel, ES2015, etc.\n\nGulp-nodemon is made to work with the \"groovy\" new tools like Babel, JSX, and other JavaScript compilers/bundlers/transpilers.\n\nIn gulp-nodemon land, you'll want one task for compilation that uses an on-disk cache (e.g. `gulp-file-cache`, `gulp-cache-money`) along with your bundler (e.g. `gulp-babel`, `gulp-react`, etc.). Then you'll put `nodemon({})` in another task and pass the entire compile task in your config:\n\n```js\nvar gulp = require('gulp')\n  , nodemon = require('gulp-nodemon')\n  , babel = require('gulp-babel')\n  , Cache = require('gulp-file-cache')\n\nvar cache = new Cache();\n\ngulp.task('compile', function () {\n  var stream = gulp.src('./src/**/*.js') // your ES2015 code\n                   .pipe(cache.filter()) // remember files\n                   .pipe(babel({ ... })) // compile new ones\n                   .pipe(cache.cache()) // cache them\n                   .pipe(gulp.dest('./dist')) // write them\n  return stream // important for gulp-nodemon to wait for completion\n})\n\ngulp.task('watch', ['compile'], function (done) {\n  var stream = nodemon({\n                 script: 'dist/' // run ES5 code\n               , watch: 'src' // watch ES2015 code\n               , tasks: ['compile'] // compile synchronously onChange\n               , done: done\n               })\n\n  return stream\n})\n```\n\nThe cache keeps your development flow moving quickly and the `return stream` line ensure that your tasks get run in order. If you want them to run async, just remove that line.\n\n## Using `gulp-nodemon` with `browser-sync`\n\nSome people want to use `browser-sync`. That's totally fine, just start browser sync in the same task as `nodemon({})` and use gulp-nodemon's `.on('start', function () {})` to trigger browser-sync. Don't use the `.on('restart')` event because it will fire before your app is up and running.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolemangariety%2Fgulp-nodemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolemangariety%2Fgulp-nodemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolemangariety%2Fgulp-nodemon/lists"}