Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._parseArgs = function parseArgs (args, shortCircuit, _skipValidation, commandIndex) {
let skipValidation = !!_skipValidation
args = args || processArgs
options.__ = y18n.__
options.configuration = self.getParserConfiguration()
// Deprecated
let pkgConfig = pkgUp()['yargs']
if (pkgConfig) {
console.warn('Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.')
options.configuration = Object.assign({}, pkgConfig, options.configuration)
}
const parsed = Parser.detailed(args, options)
let argv = parsed.argv
if (parseContext) argv = Object.assign({}, argv, parseContext)
const aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
try {
guessLocale() // guess locale lazily, so that it can be turned off in chain.
// while building up the argv object, there
// are two passes through the parser. If completion
// is being performed short-circuit on the first pass.
if (shortCircuit) {
return argv
}
// kill(2) Ctrl-C
process.once('SIGINT', () => onSignal('SIGINT'));
// kill(3) Ctrl-\
process.once('SIGQUIT', () => onSignal('SIGQUIT'));
// kill(15) default
process.once('SIGTERM', () => onSignal('SIGTERM'));
function onSignal() {
if (closed) return;
closed = true;
process.exit(0);
}
process.env.NODE_ENV = 'development';
const args = yParser(process.argv.slice(2));
const Service = require('umi-build-dev/lib/Service').default;
new Service(buildDevOpts(args)).run('dev', args);
import { dirname } from 'path';
import yParser from 'yargs-parser';
import signale from 'signale';
import semver from 'semver';
import ora from 'ora';
import buildDevOpts from './buildDevOpts';
const spinner = ora();
const script = process.argv[2];
const args = yParser(process.argv.slice(3));
// Node version check
const nodeVersion = process.versions.node;
if (semver.satisfies(nodeVersion, '<6.5')) {
signale.error(`Node version must >= 6.5, but got ${nodeVersion}`);
process.exit(1);
}
spinner.start('🏃 parsing parameters');
// Notify update when process exits
const updater = require('update-notifier');
const pkg = require('../package.json');
updater({ pkg }).notify({ defer: true });
process.env.UMI_DIR = dirname(require.resolve('../package'));
process.env.UMI_VERSION = pkg.version;
}
this.deleteMessages()
const tool: string = (atom.config.get('go-plus.lint.tool'): any)
const cmd = await this.goconfig.locator.findTool(tool)
if (!cmd) {
return
}
const options = this.goconfig.executor.getOptions('file', editor)
let configuredArgs: string | string[] = (atom.config.get(
'go-plus.lint.args'
): any)
if (typeof configuredArgs === 'string') {
configuredArgs = configuredArgs ? argparser(configuredArgs) : []
}
let args = TOOLS[tool.toLowerCase()].prepareArgs(configuredArgs)
args = replaceVariables(args, editor.getPath(), options)
const r: ExecResult = await this.goconfig.executor.exec(cmd, args, options)
if (!r) {
return
}
const stderr = r.stderr instanceof Buffer ? r.stderr.toString() : r.stderr
const stdout = r.stdout instanceof Buffer ? r.stdout.toString() : r.stdout
if (stderr && stderr.trim() !== '') {
console.log(`${tool}-linter: (stderr) ` + stderr) // eslint-disable-line no-console
}
let messages: Array = []
if (stdout && stdout.trim() !== '') {
function parseArgs (args, shortCircuit) {
options.__ = y18n.__
options.configuration = pkgConf.sync('yargs', {
defaults: {},
cwd: requireMainFilename(require)
})
const parsed = Parser.detailed(args, options)
const argv = parsed.argv
var aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
guessLocale() // guess locale lazily, so that it can be turned off in chain.
// while building up the argv object, there
// are two passes through the parser. If completion
// is being performed short-circuit on the first pass.
if (shortCircuit) {
return argv
}
// if there's a handler associated with a
function parseArgs (args, shortCircuit) {
options.__ = y18n.__
options.configuration = pkgUp(cwd)['yargs'] || {}
const parsed = Parser.detailed(args, options)
const argv = parsed.argv
var aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
guessLocale() // guess locale lazily, so that it can be turned off in chain.
// while building up the argv object, there
// are two passes through the parser. If completion
// is being performed short-circuit on the first pass.
if (shortCircuit) {
return argv
}
// if there's a handler associated with a
const unparsed = []
Object.keys(positionalMap).forEach((key) => {
positionalMap[key].map((value) => {
unparsed.push(`--${key}`)
unparsed.push(value)
})
})
// short-circuit parse.
if (!unparsed.length) return
const config = Object.assign({}, options.configuration, {
'populate--': true
})
const parsed = Parser.detailed(unparsed, Object.assign({}, options, {
configuration: config
}))
if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
} else {
// only copy over positional keys (don't overwrite
// flag arguments that were already parsed).
const positionalKeys = Object.keys(positionalMap)
Object.keys(positionalMap).forEach((key) => {
[].push.apply(positionalKeys, parsed.aliases[key])
})
Object.keys(parsed.argv).forEach((key) => {
if (positionalKeys.indexOf(key) !== -1) {
// any new aliases need to be placed in positionalMap, which
options.default = Object.assign(parseOptions.default, options.default)
options.alias = Object.assign(parseOptions.alias, options.alias)
options.array = options.array.concat(parseOptions.array)
const unparsed = []
Object.keys(positionalMap).forEach((key) => {
positionalMap[key].map((value) => {
unparsed.push(`--${key}`)
unparsed.push(value)
})
})
// short-circuit parse.
if (!unparsed.length) return
const parsed = Parser.detailed(unparsed, options)
if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
} else {
// only copy over positional keys (don't overwrite
// flag arguments that were already parsed).
const positionalKeys = Object.keys(positionalMap)
Object.keys(positionalMap).forEach((key) => {
[].push.apply(positionalKeys, parsed.aliases[key])
})
Object.keys(parsed.argv).forEach((key) => {
if (positionalKeys.indexOf(key) !== -1) {
argv[key] = parsed.argv[key]
}
})
self._parseArgs = function (args, shortCircuit, _skipValidation) {
var skipValidation = !!_skipValidation
args = args || processArgs
options.__ = y18n.__
options.configuration = pkgUp()['yargs'] || {}
const parsed = Parser.detailed(args, options)
var argv = parsed.argv
if (parseContext) argv = assign(argv, parseContext)
var aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
try {
guessLocale() // guess locale lazily, so that it can be turned off in chain.
// while building up the argv object, there
// are two passes through the parser. If completion
// is being performed short-circuit on the first pass.
if (shortCircuit) {
return argv
}
self._parseArgs = function (args, shortCircuit, _skipValidation, commandIndex) {
var skipValidation = !!_skipValidation
args = args || processArgs
options.__ = y18n.__
options.configuration = pkgUp()['yargs'] || {}
const parsed = Parser.detailed(args, options)
var argv = parsed.argv
if (parseContext) argv = assign(argv, parseContext)
var aliases = parsed.aliases
argv.$0 = self.$0
self.parsed = parsed
try {
guessLocale() // guess locale lazily, so that it can be turned off in chain.
// while building up the argv object, there
// are two passes through the parser. If completion
// is being performed short-circuit on the first pass.
if (shortCircuit) {
return argv
}