├── .gitignore ├── .jshintrc ├── .travis.yml ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "maxlen" : 120, 3 | "maxdepth" : 5, 4 | "maxstatements" : 40, 5 | 6 | "passfail" : false, 7 | "node" : true, 8 | "browser" : true, 9 | 10 | "debug" : true, // Allow debugger statements e.g. browser breakpoints. 11 | "devel" : true, // Allow development statements e.g. `console.log();`. 12 | 13 | "esnext" : true, // Allow EcmaScript 5 syntax. 14 | "strict" : true, // Require `use strict` pragma in every file. 15 | "globalstrict" : true, // Allow global "use strict" (also enables "strict"). 16 | 17 | "undef" : true, 18 | "laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. 19 | "laxcomma" : false, 20 | "curly" : false, // Require {} for every new block or scope. 21 | "eqeqeq" : true, // Require triple equals i.e. `===`. 22 | "eqnull" : true, // Tolerate use of `== null`. 23 | "expr" : true, // Tolerate `ExpressionStatement` as Programs. 24 | "forin" : false, // Prohibt `for in` loops without `hasOwnProperty`. 25 | "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` 26 | "latedef" : false, // Prohibit variable use before definition. 27 | "loopfunc" : false, // Allow functions to be defined within loops. 28 | "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. 29 | "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions. 30 | "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. 31 | "scripturl" : false, // Tolerate script-targeted URLs. 32 | "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. 33 | "undef" : true, // Require all non-global variables be declared before they are used. 34 | "unused" : "vars", 35 | 36 | "newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`. 37 | "noempty" : true, // Prohibit use of empty blocks. 38 | "nonew" : true, // Prohibit use of constructors for side-effects. 39 | "nomen" : false, // Prohibit use of initial or trailing underbars in names. 40 | "onevar" : false, // Allow only one `var` statement per function. 41 | "plusplus" : false, // Prohibit use of `++` & `--`. 42 | "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict["key"]` instead of `dict.key`. 43 | "trailing" : true, // Prohibit trailing whitespaces. 44 | "white" : false, // Check against strict whitespace and indentation rules. 45 | "quotmark" : false, 46 | "validthis" : true, 47 | 48 | "predef" : ["it", "describe", "before", "after", "beforeEach", "afterEach"] 49 | } 50 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Adam Babik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gulp-exit 2 | ========= 3 | 4 | `gulp-exit` ensures that the task is terminated after finishing. 5 | 6 | Some plugins, like [gulp-mocha](https://github.com/sindresorhus/gulp-mocha), have problems with a proper termination after finishing the task. This plugin guarantees that the task will exit successfully. 7 | 8 | ### Example 9 | 10 | ```javascript 11 | var mocha = require('gulp-mocha'), 12 | exit = require('gulp-exit'); 13 | 14 | gulp.src('test.js') 15 | .pipe(mocha({ 16 | reporter: 'dot', 17 | ui: 'bdd', 18 | growl: true, 19 | timeout: 2000, 20 | useColors: true, 21 | useInlineDiffs: true 22 | })) 23 | .pipe(exit()); 24 | ``` 25 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var stream = require('stream'); 4 | var util = require('util'); 5 | 6 | /** 7 | * Node v0.10+ uses native `Transform`. For older versions, use a polyfill. 8 | * 9 | * @type {Function} 10 | */ 11 | 12 | var Transform = stream.Transform || require('readable-stream').Transform; 13 | 14 | /** 15 | * `Exit` constructor. 16 | * 17 | * @param {Object} options 18 | */ 19 | 20 | function Exit(options) { 21 | if (!(this instanceof Exit)) return new Exit(options); 22 | Transform.call(this, options); 23 | } 24 | 25 | /** 26 | * Inherit from `Transform`. 27 | */ 28 | 29 | util.inherits(Exit, Transform); 30 | 31 | /** @type {Object} */ 32 | var exitProto = Exit.prototype; 33 | 34 | /** 35 | * Override required methods. 36 | */ 37 | 38 | exitProto._transform = function (c, e, cb) { cb(); }; 39 | 40 | exitProto._flush = function (cb) { 41 | cb(); 42 | process.exit(0); 43 | }; 44 | 45 | /** 46 | * Exports as a gulp plugin. 47 | */ 48 | 49 | module.exports = function () { 50 | return new Exit({ objectMode: true }); 51 | }; 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-exit", 3 | "version": "0.0.2", 4 | "description": "Terminates gulp task.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/dreame4/gulp-exit.git" 12 | }, 13 | "keywords": [ 14 | "gulp", 15 | "gulpplugin", 16 | "exit", 17 | "terminate" 18 | ], 19 | "author": "Adam Babik", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/dreame4/gulp-exit/issues" 23 | }, 24 | "homepage": "https://github.com/dreame4/gulp-exit" 25 | } 26 | --------------------------------------------------------------------------------