From 3f2dc44f7ac9cff93257af8043a7b77292c39321 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Sat, 12 Sep 2015 15:34:36 +0900 Subject: [PATCH] Add gulp-shell --- gulp-shell/gulp-shell-tests.ts | 42 +++++++++++++++++++++ gulp-shell/gulp-shell.d.ts | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 gulp-shell/gulp-shell-tests.ts create mode 100644 gulp-shell/gulp-shell.d.ts diff --git a/gulp-shell/gulp-shell-tests.ts b/gulp-shell/gulp-shell-tests.ts new file mode 100644 index 000000000..eb3d1a5a4 --- /dev/null +++ b/gulp-shell/gulp-shell-tests.ts @@ -0,0 +1,42 @@ +/// +/// + +import shell = require('gulp-shell'); +import gulp = require('gulp'); + +gulp.task('example', function () { + return gulp.src('*.js', {read: false}) + .pipe(shell([ + 'echo <%= f(file.path) %>', + 'ls -l <%= file.path %>' + ], { + templateData: { + f: function (s: string) { + return s.replace(/$/, '.bak') + } + } + })) +}); + +gulp.task('shorthand', shell.task([ + 'echo hello', + 'echo world' +])); + +var paths: any = { + js: ['*.js', 'test/*.js'] +}; + +gulp.task('test', shell.task('mocha -R spec')); + +gulp.task('coverage', ['test'], shell.task('istanbul cover _mocha -- -R spec')); + +gulp.task('coveralls', ['coverage'], shell.task('cat coverage/lcov.info | coveralls')); + +gulp.task('lint', shell.task('eslint ' + paths.js.join(' '))); + +gulp.task('default', ['coverage', 'lint']); + +gulp.task('watch', function () { + gulp.watch(paths.js, ['default']) +}); diff --git a/gulp-shell/gulp-shell.d.ts b/gulp-shell/gulp-shell.d.ts new file mode 100644 index 000000000..d88f27ed6 --- /dev/null +++ b/gulp-shell/gulp-shell.d.ts @@ -0,0 +1,68 @@ +// Type definitions for gulp-shell +// Project: https://github.com/sun-zheng-an/gulp-shell +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-shell" { + + namespace shell { + interface Shell { + (commands: string|string[], options?: Option): NodeJS.ReadWriteStream; + task(commands: string|string[], options?: Option): () => NodeJS.ReadWriteStream; + } + + interface Option { + /** + * You can add a custom error message for when the command fails. This can be a template which can be + * interpolated with the current command, some file info (e.g. file.path) and some error info + * (e.g. error.code). + * @default 'Command `<%= command %>` failed with exit code <%= error.code %>' + */ + errorMessage?: string; + /** + * By default, it will emit an error event when the command finishes unsuccessfully. + * @default false + */ + ignoreErrors?: boolean; + /** + * By default, it will print the command output. + * @default false + */ + quiet?: boolean; + /** + * Sets the current working directory for the command. + * @default process.cwd() + */ + cwd?: string; + /** + * The data that can be accessed in template. + */ + templateData?: any; + /** + * You won't need to set this option unless you encounter a "stdout maxBuffer exceeded" error. + * @default 16MB(16 * 1024 * 1024) + */ + maxBuffer?: number; + /** + * The maximum amount of time in milliseconds the process is allowed to run. + * @default + */ + timeout?: number; + /** + * By default, all the commands will be executed in an environment with all the variables in process.env + * and PATH prepended by ./node_modules/.bin (allowing you to run executables in your Node's dependencies). + * You can override any environment variables with this option. + * For example, setting it to {PATH: process.env.PATH} will reset the PATH + * if the default one brings your some troubles. + */ + env?: any; + } + } + + var shell: shell.Shell; + + export = shell; +} +