Add gulp-nodemon

This commit is contained in:
tkQubo 2015-09-05 01:47:55 +09:00
parent d9fea91e84
commit fb32dabdd6
2 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/// <reference path="gulp-nodemon.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
import gulp = require('gulp');
import path = require('path');
import nodemon = require('gulp-nodemon');
gulp.task('start', function () {
nodemon({
script: 'server.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
})
});
nodemon({
script: 'index.js'
, tasks: ['browserify']
});
nodemon({
script: './index.js'
, ext: 'js css'
, tasks: function (changedFiles: string[]): string[] {
var tasks: string[] = [];
changedFiles.forEach(function (file: string) {
if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint')
if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin')
});
return tasks
}
});
gulp.task('develop', function () {
nodemon({ script: 'server.js'
, ext: 'html js'
, ignore: ['ignored.js']
, tasks: ['lint'] })
.on('restart', function () {
console.log('restarted!')
})
});

88
gulp-nodemon/gulp-nodemon.d.ts vendored Normal file
View File

@ -0,0 +1,88 @@
// Type definitions for gulp-nodemon
// Project: https://github.com/JacksonGariety/gulp-nodemon
// Definitions by: Qubo <https://github.com/tkQubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "gulp-nodemon" {
namespace nodemon {
interface Nodemon {
(option?: Option): EventEmitter;
}
interface Option extends _Option {
tasks?: string[]|((changedFiles: string[]) => string[]);
}
// TODO: Properties may be insufficient
// TODO: In future this interface should be moved to nodemon.d.ts
interface _Option {
env?: { [key: string]: string|boolean|number; };
script?: string;
/**
* Extensions to look for, ie. js,jade,hbs.
*/
ext?: string;
/**
* Execute script with "app", ie. -x "python -v".
*/
exec?: string;
/**
* Watch directory "dir" or files. use once for each directory or file to watch.
*/
watch?: string[];
/**
* Ignore specific files or directories.
*/
ignore?: string[];
/**
* Minimise nodemon messages to start/stop only.
*/
quiet?: boolean;
/**
* Show detail on what is causing restarts.
*/
verbose?: boolean;
/**
* Try to read from stdin.
*/
stdin?: boolean;
stdout?: boolean;
/**
* Execute script on change only, not startup
*/
runOnChangeOnly?: boolean;
/**
* Debounce restart in seconds.
*/
delay?: number;
/**
* Forces node to use the most compatible version for watching file changes.
*/
legacyWatch?: boolean;
/**
* Exit on crash, allows use of nodemon with daemon tools like forever.js.
*/
exitcrash?: boolean;
execMap?: { [key: string]: string|boolean|number; };
events?: { [key: string]: string; };
restartable?: string;
}
interface EventEmitter extends NodeJS.EventEmitter {
addListener(event: string, listener: Function): EventEmitter;
addListener(event: string, tasks: string[]): EventEmitter;
on(event: string, listener: Function): EventEmitter;
on(event: string, tasks: string[]): EventEmitter;
once(event: string, listener: Function): EventEmitter;
once(event: string, tasks: string[]): EventEmitter;
}
}
var nodemon: nodemon.Nodemon;
export = nodemon;
}