Skip to content

Commit

Permalink
Init Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkalen committed Sep 8, 2017
0 parents commit 28a2b66
Show file tree
Hide file tree
Showing 13 changed files with 935 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
engines:
coffeelint:
enabled: true
config: .config/coffeelint.json
fixme:
enabled: true
ratings:
paths:
- "src/**.coffee"
exclude_paths:
- test/
130 changes: 130 additions & 0 deletions .config/coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"arrow_spacing": {
"level": "ignore"
},
"braces_spacing": {
"level": "ignore",
"spaces": 0,
"empty_object_spaces": 0
},
"camel_case_classes": {
"level": "error"
},
"coffeescript_error": {
"level": "error"
},
"colon_assignment_spacing": {
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"cyclomatic_complexity": {
"value": 10,
"level": "ignore"
},
"duplicate_key": {
"level": "error"
},
"empty_constructor_needs_parens": {
"level": "ignore"
},
"ensure_comprehensions": {
"level": "ignore"
},
"eol_last": {
"level": "ignore"
},
"indentation": {
"value": 1,
"use": "tabs",
"level": "ignore"
},
"line_endings": {
"level": "ignore",
"value": "unix"
},
"max_line_length": {
"value": 80,
"level": "ignore",
"limitComments": true
},
"missing_fat_arrows": {
"level": "ignore",
"is_strict": false
},
"newlines_after_classes": {
"value": 3,
"level": "ignore"
},
"no_backticks": {
"level": "error"
},
"no_debugger": {
"level": "ignore",
"console": false
},
"no_empty_functions": {
"level": "ignore"
},
"no_empty_param_list": {
"level": "ignore"
},
"no_implicit_braces": {
"level": "ignore",
"strict": true
},
"no_implicit_parens": {
"strict": true,
"level": "ignore"
},
"no_interpolation_in_single_quotes": {
"level": "error"
},
"no_plusplus": {
"level": "ignore"
},
"no_stand_alone_at": {
"level": "ignore"
},
"no_tabs": {
"level": "ignore"
},
"no_this": {
"level": "error"
},
"no_throwing_strings": {
"level": "error"
},
"no_trailing_semicolons": {
"level": "ignore"
},
"no_trailing_whitespace": {
"level": "ignore",
"allowed_in_comments": false,
"allowed_in_empty_lines": true
},
"no_unnecessary_double_quotes": {
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"level": "warn"
},
"non_empty_constructor_needs_parens": {
"level": "ignore"
},
"prefer_english_operator": {
"level": "ignore",
"doubleNotLevel": "ignore"
},
"space_operators": {
"level": "ignore"
},
"spacing_after_comma": {
"level": "ignore"
},
"transform_messes_up_line_numbers": {
"level": "warn"
}
}
Binary file added .config/img/demo1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .config/img/demo2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules/

coverage/

config.codekit

*.sublime-*

data

.codekit-cache

*.sassc

logfile

logs/error.log

*.log

settings-db.json

build/
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# inspector-on-demand
[![Code Climate](https://codeclimate.com/github/danielkalen/inspector-on-demand/badges/gpa.svg)](https://codeclimate.com/github/danielkalen/inspector-on-demand)
[![NPM](https://img.shields.io/npm/v/inspector-on-demand.svg)](https://npmjs.com/package/inspector-on-demand)
[![NPM](https://img.shields.io/npm/dm/inspector-on-demand.svg)](https://npmjs.com/package/inspector-on-demand)

Launch v8 inspector/chrome-dev-tools on-demand for long-running apps. Requires node >= v8.0.0, otherwise dev

## Demo
[![Demo 1](.config/img/demo1.png?raw=true)](https://github.com/danielkalen/inspector-on-demand)
[![Demo 2](.config/img/demo2.png?raw=true)](https://github.com/danielkalen/inspector-on-demand)


## Usage
Load the `inspector-on-demand` module at any point in your app using `require('inspector-on-demand')` and type any of the following commands in your terminal to launch the inspector:

- `CTRL+Y` - activate inspector listener. This will not pause further script execution.
- `CTRL+U` - activate inspector listener and pause further script execution until inspector is open.
- `CTRL+X` - deactivate inspector listener. After this combo, the inspector cannot be re-enabled.

Then launch chrome and navigate to `chrome://inspect` and launch the newly added remote target. If you are having trouble launching the inspector you might want to consider using [NiM Inspector Manager Chrome Extension](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en).







## License
MIT © [Daniel Kalen](https://github.com/danielkalen)
20 changes: 20 additions & 0 deletions index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
term = require('terminal-kit').terminal
count = 0

setInterval ()->
console.log 'count',require('chalk').red(count)
,2500
term.grabInput()
term.on 'key', (name,matches,data)->
if name is 'CTRL_C'
# process.exit()
;
else
if name is 'CTRL_U'
console.log 'pressed CTRL_U'
count++
term.grabInput(false)
# term.on 'CTRL_I', ()-> console.log 'CTRL_I!'; count++
# term.on 'CTRL_F', ()-> console.log 'CTRL_F!'; count++
# term.on 'T', ()-> console.log 'T!'; count++

2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('coffee-register');
module.exports = require('./lib/index');
43 changes: 43 additions & 0 deletions lib/index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
nodeVersion = parseFloat process.version.slice(1)
supportsInspector = nodeVersion >= 8
port = process.env.INSPECTOR_PORT
host = process.env.INSPECTOR_HOST

if supportsInspector
term = require('terminal-kit').terminal
term.grabInput(true)
inspector = require 'inspector'

term.on 'key', (key)->
inspectorURL = inspector.url()
switch
when key is 'CTRL_C'
term.processExit()

when (key is 'CTRL_Y' or key is 'CTRL_U') and inspectorURL
term.dim inspectorURL+'\n'

when key is 'CTRL_Y'
inspector.open(port, host, false)

when key is 'CTRL_U'
inspector.open(port, host, true)

when key is 'CTRL_X' and inspectorURL
term.dim 'deactivating inspector\n'
inspector.close()
term.grabInput(false)


else if process.env.INSPECTOR_SUPPORT
console.warn "
inspector-on-demand is unsupported by your verison of node
(requires >=v8.0.0; current #{process.verison})
"







Loading

0 comments on commit 28a2b66

Please sign in to comment.