mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
- Update yargs to 16.1.1 - Update @rollup/plugin-commonjs to 17.0.0 - Update @types/codemirror to 0.0.100 - Update Puppeteer to 5.5.0 - Update Rollup to 2.34.0 DISABLE_THIRD_PARTY_CHECK=NPM update R=jacktfranklin@chromium.org Change-Id: Ie3ed95b7c83ec615122643769ff5c53ac4111c09 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2567910 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
'use strict';
|
|
// classic singleton yargs API, to use yargs
|
|
// without running as a singleton do:
|
|
// require('yargs/yargs')(process.argv.slice(2))
|
|
const {Yargs, processArgv} = require('./build/index.cjs');
|
|
|
|
Argv(processArgv.hideBin(process.argv));
|
|
|
|
module.exports = Argv;
|
|
|
|
function Argv(processArgs, cwd) {
|
|
const argv = Yargs(processArgs, cwd, require);
|
|
singletonify(argv);
|
|
return argv;
|
|
}
|
|
|
|
/* Hack an instance of Argv with process.argv into Argv
|
|
so people can do
|
|
require('yargs')(['--beeble=1','-z','zizzle']).argv
|
|
to parse a list of args and
|
|
require('yargs').argv
|
|
to get a parsed version of process.argv.
|
|
*/
|
|
function singletonify(inst) {
|
|
Object.keys(inst).forEach(key => {
|
|
if (key === 'argv') {
|
|
Argv.__defineGetter__(key, inst.__lookupGetter__(key));
|
|
} else if (typeof inst[key] === 'function') {
|
|
Argv[key] = inst[key].bind(inst);
|
|
} else {
|
|
Argv.__defineGetter__('$0', () => {
|
|
return inst.$0;
|
|
});
|
|
Argv.__defineGetter__('parsed', () => {
|
|
return inst.parsed;
|
|
});
|
|
}
|
|
});
|
|
}
|