diff --git a/lib/_inspect.js b/lib/_inspect.js index 5cd1cc2..2a6113b 100644 --- a/lib/_inspect.js +++ b/lib/_inspect.js @@ -24,8 +24,10 @@ const { spawn } = require('child_process'); const { EventEmitter } = require('events'); const util = require('util'); +const runAsStandalone = typeof __dirname !== 'undefined'; + const [ InspectClient, createRepl ] = - (typeof __dirname !== 'undefined') ? + runAsStandalone ? // This copy of node-inspect is on-disk, relative paths make sense. [ require('./internal/inspect_client'), @@ -258,8 +260,12 @@ function startInspect(argv = process.argv.slice(2), stdout = process.stdout) { /* eslint-disable no-console */ if (argv.length < 1) { - console.error('Usage: node-inspect script.js'); - console.error(' node-inspect :'); + const invokedAs = runAsStandalone ? + 'node-inspect' : + `${process.argv0} ${process.argv[1]}`; + + console.error(`Usage: ${invokedAs} script.js`); + console.error(` ${invokedAs} :`); process.exit(1); }