# gulp-develop-server

> run node.js server and automatically restart for your development.

Latest version **0.5.2** (published 2016-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-develop-server
pnpm add gulp-develop-server
yarn add gulp-develop-server
bun add gulp-develop-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.2 |
| Published | 2016-05-28 |
| First published | 2014-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Maintainers | narirou |
| Keywords | gulpplugin, gulp, server, restart, express |

## Links

- npm: https://www.npmjs.com/package/gulp-develop-server
- Repository: https://github.com/narirou/gulp-develop-server
- Homepage: https://github.com/narirou/gulp-develop-server#readme
- Issues: https://github.com/narirou/gulp-develop-server/issues
- npm.io page: https://npm.io/package/gulp-develop-server

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.13.1
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.3

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 0.5.2 (latest) — 2016-05-28
- 0.5.1 — 2016-03-05
- 0.5.0 — 2015-11-03
- 0.4.3 — 2015-05-21
- 0.4.2 — 2015-03-25
- 0.4.1 — 2015-03-15
- 0.4.0 — 2015-03-03
- 0.3.0 — 2015-02-24
- 0.2.5 — 2014-11-15
- 0.2.4 — 2014-10-12
- 0.2.1 — 2014-10-12
- 0.2.0 — 2014-09-09
- 0.1.7 — 2014-07-27
- 0.1.6 — 2014-07-21
- 0.1.5 — 2014-07-06
- … 10 more at https://npm.io/package/gulp-develop-server/versions

## README

gulp-develop-server
===================

> run your node.js server and automatically restart with gulp.

[![Build Status][travis-image]][travis-url]
[![Dependency Status][deps-image]][deps-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Npm Modules][npm-image]][npm-url]
[![MIT Licensed][license-image]][license-url]

[travis-image]: https://img.shields.io/travis/narirou/gulp-develop-server.svg?style=flat-square
[travis-url]: https://travis-ci.org/narirou/gulp-develop-server
[coveralls-image]: https://img.shields.io/coveralls/narirou/gulp-develop-server.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/narirou/gulp-develop-server
[npm-image]: http://img.shields.io/npm/v/gulp-develop-server.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/gulp-develop-server
[deps-image]: https://img.shields.io/david/narirou/gulp-develop-server.svg?label=deps&style=flat-square
[deps-url]: https://david-dm.org/narirou/gulp-develop-server
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
[license-url]: ./LICENSE

gulp-develop-server is a development assistant for node.js server that runs
the process and automatically restarts it when a file is modified. 



installation
------------

```bash
npm install gulp-develop-server --save-dev
```



usage
-----

```javascript
var gulp   = require( 'gulp' ),
    server = require( 'gulp-develop-server' );

// run server
gulp.task( 'server:start', function() {
    server.listen( { path: './app.js' } );
});

// restart server if app.js changed
gulp.task( 'server:restart', function() {
    gulp.watch( [ './app.js' ], server.restart );
});
```



api
---

###server.listen( options[, callback] )

**options {Object}**  

- `path`  
    - type: {String}
    - example: `'./your_node_app.js'`
    - Your node application path. This option is required.

- `env`  
    - type: {Object}  
    - default: `{ NODE_ENV: 'development' }` (extends current `process.env`)  
    - example: `{ PORT: 3000, NODE_ENV: 'production' }`  
    - Environment settings of your server.  

- `cwd`  
    - type: {String}  
    - default: `.`
    - example: `path/to/my/project/`  
    - Current working directory of the child process  

- `args`
    - type: {Array}  
    - your application's arguments

- `execArgv`  
    - type: {Array}  
    - example: `[ '--harmony' ]`  
    - Run node process with this options.  

- `delay`   
    - type: {Number}  
    - default: `600`  
    - If this plugin does not receive an error from the server after `options.delay` seconds,
    assumes the server listening success.
    - This option needs to adjust according to your application's initialize time.
    - If this option set `0`, it will only check `successMessage`.  

- `successMessage`  
    - type: {RegExp}
    - default: `/^[Ss]erver listening/`  
    - If your application send the specific message by `process.send` method,
    this plugin assumes the server listening success.

- `errorMessage`  
    - type: {RegExp}
    - default: `/[Ee]rror:/` 
    - If this plugin receives the specific error message that matched this RegExp at start-up, 
    assumes the server has error.

- `killSignal`  
    - type: {String}
    - default: `SIGTERM`

**callback( error )**  


###server.restart( [callback] ) / server.changed( [callback] )

**callback( error )**  


###server( [options] )

Create a `Transform` stream.
Restart the server at once when this stream gets files.


###server.kill( [signal, callback] )

Send kill signal to the server process.  
**signal {String}**  
**callback( error )**  


###server.reset( [signal, callback] )

Send kill signal to the server process and reset the options to default.   
**signal {String}**  
**callback( error )**  



more examples
-------------

####with [gulp-livereload](https://github.com/vohof/gulp-livereload):

```javascript
var gulp       = require( 'gulp' ),
    server     = require( 'gulp-develop-server' ),
    livereload = require( 'gulp-livereload' );

var options = {
    path: './apps/app.js'
};

var serverFiles = [
    './apps/app.js',
    './routes/*.js'
];

gulp.task( 'server:start', function() {
    server.listen( options, livereload.listen );
});

// If server scripts change, restart the server and then livereload.
gulp.task( 'default', [ 'server:start' ], function() {
    
    function restart( file ) {
        server.changed( function( error ) {
            if( ! error ) livereload.changed( file.path );
        });
    }

    gulp.watch( serverFiles ).on( 'change', restart );
});
```


####with [BrowserSync](https://github.com/BrowserSync/browser-sync):

```javascript
var gulp   = require( 'gulp' ),
    server = require( 'gulp-develop-server' ),
    bs     = require( 'browser-sync' );

var options = {
    server: {
        path: './apps/app.js',
        execArgv: [ '--harmony' ]
    },
    bs: {
        proxy: 'http://localhost:3000'
    }
};

var serverFiles = [
    './apps/app.js',
    './routes/*.js'
];

gulp.task( 'server:start', function() {
    server.listen( options.server, function( error ) {
        if( ! error ) bs( options.bs );
    });
});

// If server scripts change, restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
    server.restart( function( error ) {
        if( ! error ) bs.reload();
    });
});

gulp.task( 'default', [ 'server:start' ], function() {
    gulp.watch( serverFiles, [ 'server:restart' ] )
});
```


####use as a stream:

```javascript
var gulp   = require( 'gulp' ),
    server = require( 'gulp-develop-server' ),
    bs     = require( 'browser-sync' ),
    coffee = require( 'gulp-coffee' );

var options = {
    server: {
        path: './apps/app.js',
        execArgv: [ '--harmony' ]
    },
    bs: {
        proxy: 'http://localhost:3000'
    }
};

var serverCoffee = [
    './src/*.coffee'
];

gulp.task( 'server:start', function() {
    server.listen( options.server, function( error ) {
        if( ! error ) bs( options.bs );
    });
});

// If server side's coffee files change, compile these files,
// restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
    gulp.src( serverCoffee )
        .pipe( coffee() )
        .pipe( gulp.dest( './apps' ) )
        .pipe( server() )
        .pipe( bs.reload({ stream: true }) );
});

gulp.task( 'default', [ 'server:start' ], function() {
    gulp.watch( serverCoffee, [ 'server:restart' ] );
});
```



thanks
------

[@pronebird](https://github.com/pronebird)  
[@vkareh](https://github.com/vkareh)  
[@chimerast](https://github.com/chimerast)  
[@silverbp](https://github.com/silverbp)  
[@tomxtobin](https://github.com/tomxtobin)

---
_Source: https://npm.io/package/gulp-develop-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
