Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
export default (input: string): ?string => {
const formattedInput = input.replace(/(\s)+/g, ' ').trim();
const parsedInput: {
+_: Array,
+[flag: string]: RawValue,
} = parser(formattedInput);
const { _: command, ...params } = parsedInput;
if (
command[0] !== 'docker' ||
(command[1] !== 'run' && command[1] !== 'create')
) {
throw new SyntaxError('must be a valid docker run/create command');
}
// The service object that we'll update
let service = {};
// Loop through the tokens and append to the service object
Object.entries(params).forEach(
// https://github.com/facebook/flow/issues/2174
// $FlowFixMe: Object.entries wipes out types ATOW
/* eslint-disable no-param-reassign, comma-dangle, no-magic-numbers, dot-notation */
import fs from 'fs';
import path from 'path';
import JSON5 from 'json5';
import babel from 'rollup-plugin-babel';
import common from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import yargs from 'yargs-parser';
const options = yargs(process.argv.slice(2));
const extensions = ['.js', '.jsx', '.json'];
// Modify Babel config a bit
const babelConfig = JSON5.parse(fs.readFileSync(
path.join(__dirname, `babel${options.node ? '.node' : ''}.json5`)
));
babelConfig.presets.forEach((preset) => {
if (Array.isArray(preset) && preset[0] === 'env') {
preset[1].modules = false;
}
});
babelConfig.exclude = 'node_modules/**';
babelConfig.runtimeHelpers = (babelConfig.plugins.indexOf('transform-runtime') >= 0);
export function applyContext(context: T): T {
context.args = parseArgs(['-a', '--foo', 'bar', 'baz']);
context.argv = ['-a', '--foo', 'bar', 'baz'];
context.cwd = BEEMO_TEST_ROOT;
context.moduleRoot = BEEMO_TEST_ROOT;
context.workspaceRoot = BEEMO_TEST_ROOT;
context.workspaces = [];
return context;
}
export function applyContext(context: T): T {
context.args = parseArgs(['-a', '--foo', 'bar', 'baz']);
context.argv = ['-a', '--foo', 'bar', 'baz'];
context.cwd = __dirname;
context.moduleRoot = __dirname;
context.workspaceRoot = __dirname;
context.workspaces = [];
return context;
}
mockChildProcessExec = (command, opts, callback) => {
let { _ : args, ...options } = yargsParser(command);
let cmd = { args, opts: options };
let res = async (text) => {
if (!callback) {
throw new Error(`Expected callback to be passed`);
}
callback(null, text, '');
await nextTick();
};
let err = async (message) => {
if (!callback) {
throw new Error(`Expected callback to be passed`);
}
callback(null, '', message);
await nextTick();
export const parseArgs = (args: string): any => yargs(args);
export const systemMessage = (message: string | Object): void => {
import argvParser from 'yargs-parser';
/**
* @private
* @type {Object}
*/
const argv = argvParser(process.argv.slice(2));
export default argv;