├── .gitignore ├── LICENSE ├── README.md ├── SECURITY.md ├── examples └── example.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (C) 2016, Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # edge-diagnostics-launch 2 | Launcher for Microsoft Edge Diagnostics Adapter to make it simpler to start an instance of the Edge with diagnostics enabled. 3 | 4 | ## Installation 5 | `npm install edge-diagnostics-launch` 6 | 7 | ## Options 8 | ```javascript 9 | { 10 | adapterPath: '', // Optional, override adaptor path 11 | port: 9222 // Optional, override socket port 12 | } 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```javascript 18 | var launch = require('edge-diagnostics-launch') 19 | var options = { 20 | adapterPath: '', // Optional, override adaptor path 21 | port: 9222 // Optional, override socket port 22 | } 23 | 24 | // launch(, , callback) 25 | var edge = launch('http://microsoft.com', options, function(err) { 26 | 27 | if (err) { 28 | console.log('Something went wrong when starting Edge', err) 29 | } else { 30 | console.log('Edge launched. Go connect') 31 | } 32 | 33 | }) 34 | 35 | edge.on('exit', function(code) { 36 | console.log('Edge has excited with code', code) 37 | }) 38 | 39 | // stdout + stderr streams from adaptor 40 | edge.stdout.on('data', function(data) { 41 | console.log('edge.stdout', data) 42 | }) 43 | 44 | edge.stderr.on('data', function(data) { 45 | console.log('edge.stderr', data) 46 | }) 47 | 48 | ``` 49 | 50 | ## License 51 | 52 | MIT. 53 | 54 | ## Code of Conduct 55 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 56 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/example.js: -------------------------------------------------------------------------------- 1 | var launch = require('../index.js') 2 | 3 | var edge = launch('http://microsoft.com', {}, function(err) { 4 | 5 | if (err) { 6 | console.log('Something went wrong when starting Edge', err) 7 | } else { 8 | console.log('Edge launched. Go connect') 9 | } 10 | 11 | }) 12 | 13 | edge.on('exit', function(code) { 14 | console.log('Edge has exited with code', code) 15 | }) 16 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var urlparse = require('url').parse 2 | var urlformat = require('url').format 3 | var child_process = require('child_process') 4 | var path = require('path') 5 | var fs = require('fs'); 6 | var os = require('os') 7 | 8 | function launch(url, options, callback) { 9 | var args = [] 10 | options = options || {} 11 | 12 | if (options.port) { 13 | args.push('--port', options.port); 14 | } 15 | 16 | if (url && url.length) { 17 | var urlObj = urlparse(url, true) 18 | delete urlObj.search // url.format does not want search attribute 19 | url = urlformat(urlObj) 20 | args.push('--launch ' + url) 21 | } 22 | 23 | 24 | if (options.adapterPath) { 25 | var command = options.adapterPath 26 | } else { 27 | for (var i = 0; i < module.paths.length; i++) { 28 | var command = path.resolve(module.paths[i], 'edge-diagnostics-adapter', 29 | 'dist', os.arch(), 'EdgeDiagnosticsAdapter.exe') 30 | 31 | if (fs.existsSync(command)) { 32 | break; 33 | } 34 | } 35 | } 36 | 37 | var process = child_process.spawn(command, args) 38 | 39 | if (callback) { 40 | process.stdout.on('data', function(chunk) { 41 | if (/server listening on port \d{4}/g.test(chunk.toString('utf-8'))) { 42 | callback(null) 43 | } 44 | }) 45 | 46 | process.stderr.on('data', function(err) { 47 | callback(err) 48 | }) 49 | } 50 | 51 | return process 52 | } 53 | 54 | module.exports = launch 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "edge-diagnostics-launch", 3 | "version": "1.1.5", 4 | "description": "Launcher for Microsoft Edge Diagnostics Adapter", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "edge", 11 | "diagnostics", 12 | "devtools", 13 | "browser", 14 | "spawn", 15 | "process", 16 | "launch" 17 | ], 18 | "author": "Kenneth Auchenberg ", 19 | "license": "MIT", 20 | "dependencies": { 21 | "edge-diagnostics-adapter": "0.3.0" 22 | } 23 | } 24 | --------------------------------------------------------------------------------