-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first pass at functional prototype without subprocess support (#5)
BREAKING CHANGE: dropped subprocess support for the time being, while we march towards an initial implementation.
- Loading branch information
Showing
8 changed files
with
101 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,58 @@ | ||
#!/usr/bin/env node | ||
|
||
const argv = require('yargs').parse() | ||
const CRI = require('chrome-remote-interface') | ||
const getPort = require('get-port'); | ||
const foreground = require('foreground-child') | ||
const sw = require('spawn-wrap') | ||
const waitTillPortOpen = require('wait-till-port-open') | ||
|
||
if (argv._.length) { | ||
sw([require.resolve('./wrap')]) | ||
foreground(process.argv.slice(2)) | ||
getPort().then(async port => { | ||
foreground( | ||
['node', `--inspect-brk=${port}`].concat(process.argv.slice(2)), | ||
(done) => { | ||
console.info('actually got here') | ||
} | ||
) | ||
try { | ||
await waitTillPortOpen(port) | ||
const client = await CRI({port: port}) | ||
|
||
const {Debugger, Runtime, Profiler} = client | ||
await Runtime.runIfWaitingForDebugger() | ||
await Runtime.enable() | ||
await Profiler.enable() | ||
await Profiler.startPreciseCoverage({callCount: true, detailed: true}) | ||
await Debugger.enable() | ||
await Debugger.paused() | ||
await Debugger.resume() | ||
|
||
client.on('event', async (message) => { | ||
// console.info(message) | ||
if (message.method === 'Runtime.executionContextDestroyed') { | ||
await outputCoverage(Profiler) | ||
client.close() | ||
} | ||
}) | ||
|
||
} catch (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
}) | ||
|
||
async function outputCoverage (Profiler) { | ||
const IGNORED_PATHS = [ | ||
/\/bin\/wrap.js/, | ||
/\/node_modules\//, | ||
/node-spawn-wrap/ | ||
] | ||
let {result} = await Profiler.takePreciseCoverage() | ||
result = result.filter(coverage => { | ||
for (var ignored, i = 0; (ignored = IGNORED_PATHS[i]) !== undefined; i++) { | ||
if (ignored.test(coverage.url)) return false | ||
} | ||
if (!/^\//.test(coverage.url)) return false | ||
else return true | ||
}) | ||
console.log(JSON.stringify(result, null, 2)) | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.