├── .gitignore ├── .editorconfig ├── .jshintrc ├── package.json ├── LICENSE ├── README.md ├── .jscsrc └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_store 3 | *.log 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | root = true 5 | [*] 6 | # Change these settings to your own preference 7 | indent_style = space 8 | indent_size = 2 9 | # We recommend you to keep these unchanged 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "immed": true, 8 | "latedef": true, 9 | "newcap": true, 10 | "trailing": true, 11 | "quotmark": "single", 12 | "strict": true, 13 | "multistr": true, 14 | "debug": false, 15 | "forin": true, 16 | "undef": true, 17 | "plusplus": true, 18 | "eqeqeq": true, 19 | "validthis": false, 20 | "unused": true, 21 | "jasmine": true 22 | } 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-node-inspector", 3 | "version": "0.1.0", 4 | "description": "Run node inspector from your gulp build.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/koemei/gulp-node-inspector.git" 9 | }, 10 | "keywords": [ 11 | "gulpfriendly", 12 | "node-inspector", 13 | "debug" 14 | ], 15 | "author": "Koemei", 16 | "license": "MIT", 17 | "bugs": { 18 | "url": "https://github.com/koemei/gulp-node-inspector/issues" 19 | }, 20 | "homepage": "https://github.com/koemei/gulp-node-inspector", 21 | "dependencies": { 22 | "gulp-util": "^3.0.2", 23 | "event-stream": "^3.2.2", 24 | "node-inspector": "^0.12.2", 25 | "merge": "^1.2.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Koemei 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gulp-node-inspector 2 | 3 | A gulp-friendly node-inspector wrapper 4 | 5 | Perfect for development. 6 | 7 | ## Installation 8 | 9 | `npm install gulp-node-inspector --save-dev` 10 | 11 | ## Usage 12 | 13 | ```javascript 14 | // gulpfile.js 15 | var gulp = require('gulp'); 16 | var nodeInspector = require('gulp-node-inspector'); 17 | 18 | gulp.task('debug', function() { 19 | 20 | gulp.src([]) 21 | .pipe(nodeInspector()); 22 | }); 23 | ``` 24 | 25 | Example with all available options (default values): 26 | 27 | ```javascript 28 | // gulpfile.js 29 | var gulp = require('gulp'); 30 | var nodeInspector = require('gulp-node-inspector'); 31 | gulp.task('debug', function() { 32 | 33 | gulp.src([]) 34 | .pipe(nodeInspector({ 35 | debugPort: 5858, 36 | webHost: '0.0.0.0', 37 | webPort: 8080, 38 | saveLiveEdit: false, 39 | preload: true, 40 | inject: true, 41 | hidden: [], 42 | stackTraceLimit: 50, 43 | sslKey: '', 44 | sslCert: '' 45 | })); 46 | }); 47 | ``` 48 | 49 | Enter `gulp debug` in your shell to start the node-inspector. 50 | 51 | ## Options 52 | 53 | You can pass an object to `nodeInspector` with options [specified in node-inspector config](https://github.com/node-inspector/node-inspector#options). 54 | Options are written in camelCase style! 55 | 56 | ## License 57 | [MIT](https://github.com/koemei/gulp-node-inspector/blob/master/LICENSE) 58 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "disallowSpacesInNamedFunctionExpression": { 3 | "beforeOpeningRoundBrace": true 4 | }, 5 | "disallowSpacesInFunctionExpression": { 6 | "beforeOpeningRoundBrace": true 7 | }, 8 | "disallowSpacesInAnonymousFunctionExpression": { 9 | "beforeOpeningRoundBrace": true 10 | }, 11 | "disallowSpacesInFunctionDeclaration": { 12 | "beforeOpeningRoundBrace": true 13 | }, 14 | "disallowEmptyBlocks": true, 15 | "disallowSpacesInsideArrayBrackets": true, 16 | "disallowSpacesInsideParentheses": true, 17 | "disallowQuotedKeysInObjects": true, 18 | "disallowSpaceAfterObjectKeys": true, 19 | "disallowSpaceAfterPrefixUnaryOperators": true, 20 | "disallowSpaceBeforePostfixUnaryOperators": true, 21 | "disallowSpaceBeforeBinaryOperators": [ 22 | "," 23 | ], 24 | "disallowMixedSpacesAndTabs": true, 25 | "disallowTrailingWhitespace": true, 26 | "disallowTrailingComma": true, 27 | "disallowYodaConditions": true, 28 | "disallowKeywords": [ "with" ], 29 | "disallowMultipleLineBreaks": true, 30 | "requireSpaceBeforeBlockStatements": true, 31 | "requireParenthesesAroundIIFE": true, 32 | "requireSpacesInConditionalExpression": true, 33 | "requireMultipleVarDecl": "false", 34 | "requireBlocksOnNewline": 1, 35 | "requireCommaBeforeLineBreak": true, 36 | "requireSpaceBeforeBinaryOperators": true, 37 | "requireSpaceAfterBinaryOperators": true, 38 | "requireCamelCaseOrUpperCaseIdentifiers": true, 39 | "requireLineFeedAtFileEnd": true, 40 | "requireCapitalizedConstructors": true, 41 | "requireDotNotation": true, 42 | "requireSpacesInForStatement": true, 43 | "requireCurlyBraces": [ 44 | "do" 45 | ], 46 | "requireSpaceAfterKeywords": [ 47 | "if", 48 | "else", 49 | "for", 50 | "while", 51 | "do", 52 | "switch", 53 | "case", 54 | "return", 55 | "try", 56 | "catch", 57 | "typeof" 58 | ], 59 | "safeContextKeyword": "_this", 60 | "validateLineBreaks": "LF", 61 | "validateQuoteMarks": "'", 62 | "validateIndentation": 2 63 | } 64 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var es = require('event-stream'), 4 | gutil = require('gulp-util'), 5 | merge = require('merge'), 6 | debugServer = require('node-inspector/lib/debug-server'), 7 | Config = require('node-inspector/lib/config'), 8 | packageJson = require('node-inspector/package.json'); 9 | 10 | var PluginError = gutil.PluginError; 11 | var config = new Config([]); 12 | var DebugServer = debugServer.DebugServer; 13 | var log = gutil.log, 14 | colors = gutil.colors; 15 | 16 | var PLUGIN_NAME = 'gulp-node-inspector'; 17 | 18 | var nodeInspector = function(opt) { 19 | 20 | var stream; 21 | 22 | var startDebugServer = function() { 23 | var options = merge(config, opt); 24 | 25 | log(PLUGIN_NAME, 'is using node-inspector v' + packageJson.version); 26 | 27 | var debugServer = new DebugServer(options); 28 | 29 | debugServer.on('error', function(err) { 30 | 31 | if (err.code === 'EADDRINUSE') { 32 | log(colors.red('There is another process already listening at this address.\nChange "webPort": {port} to use a different port.')); 33 | } 34 | 35 | stream.emit('error', PluginError(PLUGIN_NAME, 'Cannot start the server at ' + config.webHost + ':' + config.webPort + '. Error: ' + (err.message || err))); 36 | }); 37 | 38 | debugServer.on('listening', function() { 39 | log(colors.green('Visit', this.address().url, 'to start debugging.')); 40 | }); 41 | 42 | debugServer.on('close', function() { 43 | done(); 44 | }); 45 | 46 | debugServer.start(config); 47 | } 48 | 49 | function done() { 50 | // End the stream if it exists 51 | if (stream) { 52 | stream.emit('end'); 53 | } 54 | } 55 | 56 | var queueFile = function(file) {}; 57 | 58 | var endStream = function() { 59 | startDebugServer(); 60 | }; 61 | 62 | // copied from gulp-karma 63 | stream = es.through(queueFile, endStream); 64 | 65 | return stream; 66 | }; 67 | 68 | module.exports = nodeInspector; 69 | --------------------------------------------------------------------------------