diff --git a/gulp-nodemon/gulp-nodemon-tests.ts b/gulp-nodemon/gulp-nodemon-tests.ts new file mode 100644 index 0000000000..6a634558ab --- /dev/null +++ b/gulp-nodemon/gulp-nodemon-tests.ts @@ -0,0 +1,43 @@ +/// +/// + +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!') + }) +}); diff --git a/gulp-nodemon/gulp-nodemon.d.ts b/gulp-nodemon/gulp-nodemon.d.ts new file mode 100644 index 0000000000..98db475fee --- /dev/null +++ b/gulp-nodemon/gulp-nodemon.d.ts @@ -0,0 +1,88 @@ +// Type definitions for gulp-nodemon +// Project: https://github.com/JacksonGariety/gulp-nodemon +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +} +