├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── assets └── nif.gif ├── nif └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | node_modules 16 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | assets/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Thorsten Lorenz. 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nif 2 | 3 | `node --inspect` a file and open devtool url in chrome via [chrome-cli](https://github.com/prasmussen/chrome-cli) 4 | 5 | ```sh 6 | nif ./myfile 7 | ``` 8 | 9 | ![assets/nif.gif](assets/nif.gif) 10 | 11 | ## Installation 12 | 13 | ### 1. Install chrome-cli 14 | 15 | _only supports OSX ATM_ 16 | 17 | brew install chrome-cli 18 | 19 | ### 2. Install nif 20 | 21 | npm install -g nif 22 | 23 | ## Requirements 24 | 25 | Node.js v6 or higher. 26 | 27 | ## Why? 28 | 29 | I just got tired of copy/pasting the `chrome-devtools://` url all the time. 30 | 31 | ## License 32 | 33 | MIT 34 | -------------------------------------------------------------------------------- /assets/nif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thlorenz/nif/20bb7f029838a7f5b8ab6d363c89a8b3f438b68e/assets/nif.gif -------------------------------------------------------------------------------- /nif: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const { spawn, execSync } = require('child_process') 3 | 4 | try { 5 | execSync('which chrome-cli', { env: process.env, stdio: 'ignore' }) 6 | } catch (err) { 7 | console.error('No chrome-cli executable found. Please install it using \nbrew install chrome-cli') 8 | process.exit(1) 9 | } 10 | 11 | const args = [ '--inspect', '--debug-brk' ].concat(process.argv.slice(2)) 12 | const { stderr } = spawn(process.execPath, args) 13 | stderr.on('data', onstderrData) 14 | 15 | let opened = false 16 | function onstderrData(d) { 17 | if (opened) return 18 | // Technically we'd have to ensure we have the complete line here, 19 | // but the first chunk is small enough that this works in most cases. 20 | // If you run into a problem please submit a PR (without any extra deps) 21 | // please. Thanks :) 22 | const lines = d.toString().split('\n') 23 | const url = lines.filter(x => x.trim().length).pop() 24 | if (!/chrome-devtools[:]\/\//.test(url)) return process.stderr.write(d) 25 | opened = true 26 | spawn('chrome-cli', [ 'open', url ], { stdio: 'inherit' }) 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nif", 3 | "version": "1.0.2", 4 | "description": "node --inspect a file and open devtool url in chrome via chrome-cli.", 5 | "bin": "nif", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/thlorenz/nif.git" 9 | }, 10 | "homepage": "https://github.com/thlorenz/nif", 11 | "keywords": [ 12 | "debug", 13 | "inspect", 14 | "devtools", 15 | "chrome" 16 | ], 17 | "author": { 18 | "name": "Thorsten Lorenz", 19 | "email": "thlorenz@gmx.de", 20 | "url": "http://thlorenz.com" 21 | }, 22 | "license": { 23 | "type": "MIT", 24 | "url": "https://github.com/thlorenz/nif/blob/master/LICENSE" 25 | }, 26 | "engine": { 27 | "node": ">=6.0" 28 | } 29 | } 30 | --------------------------------------------------------------------------------