Merge default options, project config file (if present), global commander.js options and command options.

@param {object} program commander.js program.
@param {object} command commander.js command.
@return {object}
777457
function aggregateOptions(program, command) {
	const argv = minimist(process.argv.slice(2));
	let options = _.merge({}, defaultOptions, program.opts(), command.opts());

	const configFile = path.resolve(process.cwd(), 'config/tamia.config.js');
	if (fs.existsSync(configFile)) {
		options = require(configFile)(options, argv);
	}

	return options;
}
39495
function(how){

      var _child, _cfg, patsy = this;
      var _execCmd = [];

      if(typeof this.project_cfg.project === 'undefined'){
        /**
         * Require config from the library
         *
         * @var     Object
         * @source  patsy
         */
        var config      = require('./config')({
          app_path  : opts.app_path,
          verbose   : opts.verbose,
          project_path : ''
        });
        this.project_cfg = config.load();
      }

      process.chdir(this.project_cfg.project.environment.abs_path);

      _cfg = this.project_cfg || this.config.load();

      process.chdir(opts.app_path);

      if(patsy.utils.isWin){

        _execCmd.push('cmd');
        // New args will go to cmd.exe, then we append the args passed in to the list
        // the /c part tells it to run the command.  Thanks, Windows...
        _execCmd.push('/c');
        _execCmd.push('node_modules\\.bin\\grunt');

      } else {

        _execCmd.push('node_modules/.bin/grunt');

      }

      // Append needed arguments for grunt
      _execCmd.push('--path');
      _execCmd.push(_cfg.project.environment.abs_path);
      _execCmd.push(opts.verbose ? '-v' : '');
      _execCmd.push(opts.force ? '--force' : '');
      _execCmd.push(how);


      _child = exec(_execCmd.join(' '),
        function (error, stdout, stderr) {

          util.print(stdout);

          if(stderr){

            console.log(stderr);

          }

          if (error !== null) {

            patsy.scripture.print('\n[Patsy]'.yellow + ': The grunt died!');

            if(opts.verbose){

              console.log('>> ERROR'.red + ':' , error);

            }

            process.exit(1);

          }


      });
    }
556338
function _registerCommands(basedir, globalObject) {
    var commandsDir = path.resolve(basedir, "commands");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(commandsDir);
        LOG.info("Found the following potential command files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register commands from the base directory '{}'. Error: {}", commandsDir, e);
        return;
    }

    var commands = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        if (!module.triggers || !module.handler) {
            LOG.warn("Found a module at {} but it doesn't appear to be a command handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            module.init(globalObject);
        }

        commands.push(module);
        LOG.info("Registered command from file {}", filePath);
    }

    return commands;
}
571849
function commonOptions(program) {
  return program
    .option(
      '-H, --hostname [hostname]',
      'Hostname on which the server will listen. [localhost]',
      'localhost'
    )
    .option(
      '-P, --port [port]',
      'Port on which the server will listen. [8080]',
      8080
    )
    .option(
      '-p, --packagerPort [port]',
      'Port on which the react-native packager will listen. [8081]',
      8081
    )
    .option(
      '-w, --webpackPort [port]',
      'Port on which the webpack dev server will listen. [8082]',
      8082
    )
    .option(
      '-c, --webpackConfigPath [path]',
      'Path to the webpack configuration file. [webpack.config.js]',
      'webpack.config.js'
    )
    .option(
      '--no-android',
      'Disable support for Android. [false]',
      false
    )
    .option(
      '--no-ios',
      'Disable support for iOS. [false]',
      false
    )
    .option(
      '-A, --androidEntry [name]',
      'Android entry module name. Has no effect if \'--no-android\' is passed. [index.android]',
      'index.android'
    )
    .option(
      '-I, --iosEntry [name]',
      'iOS entry module name. Has no effect if \'--no-ios\' is passed. [index.ios]',
      'index.ios'
    )
    .option(
      '--projectRoots [projectRoots]',
      'List of comma-separated paths for the react-native packager to consider as project root directories',
      null
    )
    .option(
      '--root [root]',
      'List of comma-separated paths for the react-native packager to consider as additional directories. If provided, these paths must include react-native and its dependencies.',
      null
    )
    .option(
      '--assetRoots [assetRoots]',
      'List of comma-separated paths for the react-native packager to consider as asset root directories',
      null
    )
    .option(
      '-r, --resetCache',
      'Remove cached react-native packager files [false]',
      false
    )
    .option(
      '--hasteExternals',
      // React Native 0.23 rewrites `require('HasteModule')` calls to
      // `require(42)` where 42 is an internal module id. That breaks
      // treating Haste modules simply as commonjs modules and leaving
      // the `require()` call in the source. So for now this feature
      // only works with React Native <0.23.
      'Allow direct import of React Native\'s (<0.23) internal Haste modules [false]',
      false
    );
}
790183
function SetupCLI(execName, packageJson, Commands, args) {
  assert(_.isString(execName), 'execName must be a string.');
  assert(_.isObject(packageJson), 'packageJson must be an object.');
  assert(_.isObject(Commands), 'Command collection must be an object.');
  assert(_.isObject(args), 'Arguments must be an object.');

  // --version or -v triggers npm version check.
  if (args.version || args.v) {
    const progName = packageJson.title || packageJson.name || process.argv[0];
    console.log(`${progName} ${ShowVersion(packageJson)}`);
    return process.exit(0);
  }

  // Remove 'color' flags if present.
  if ('color' in args) {
    delete args.color;
  }

  // The first positional (non-option) argument is the sub-command to run.
  const cmdName = _.first(args._);
  if (!cmdName) {
    console.error(GetCommandList(execName, packageJson, Commands));
    return process.exit(1);
  }
  const cmd = global.COMMAND = Commands[cmdName];
  if (!cmd) {
    console.error(col.fatal(`Unknown command "${col.bold(cmdName)}".`));
    return process.exit(1);
  }

  // Show command-specific help.
  if (args.help || args.h) {
    console.error(GetCommandUsage(execName, packageJson, cmd, args));
    return process.exit(1);
  }

  // Parse command-line parameters
  try {
    args = ParseArguments(cmd, args);
  } catch (e) {
    console.error(col.fatal(e.message));
    return process.exit(1);
  }

  return args;
}
418331
function(compose, project, opts) {

    // Default options
    var defaults = {
      force: true,
      volumes: true
    };

    // Get opts
    var options = (opts) ? _.merge(defaults, opts) : defaults;

    // Build the command and run it
    var cmd = buildCmd(compose, project, 'rm', options);
    return shCompose(cmd, {
      app: opts.app,
      mode: 'collect'
    });
  }
170701
function mergeConfig(/* config objects ... */) {
	return helpers$1.merge({}, [].slice.call(arguments), {
		merger: function(key, target, source, options) {
			var tval = target[key] || {};
			var sval = source[key];

			if (key === 'scales') {
				// scale config merging is complex. Add our own function here for that
				target[key] = mergeScaleConfig(tval, sval);
			} else if (key === 'scale') {
				// used in polar area & radar charts since there is only one scale
				target[key] = helpers$1.merge(tval, [core_scaleService.getScaleDefaults(sval.type), sval]);
			} else {
				helpers$1._merger(key, target, source, options);
			}
		}
	});
}
416833
function version(program, projectPath) {
	const prog = Object.assign({}, getDefaults(), program || {});

	const projPath = path.resolve(
		process.cwd(),
		projectPath || prog.args[0] || ""
	);

	const programOpts = Object.assign({}, prog, {
		android: path.join(projPath, prog.android),
		ios: path.join(projPath, prog.ios)
	});

	const targets = [].concat(programOpts.target, env.target).filter(Boolean);
	var appPkg;

	try {
		resolveFrom(projPath, "react-native");
		appPkg = require(path.join(projPath, "package.json"));
	} catch (err) {
		if (err.message === "Cannot find module 'react-native'") {
			log({
				style: "red",
				text: `Is this the right folder? ${err.message} in ${projPath}`
			});
		} else {
			log({
				style: "red",
				text: err.message
			});

			log({
				style: "red",
				text:
					"Is this the right folder? Looks like there isn't a package.json here"
			});
		}

		log({
			style: "yellow",
			text: "Pass the project path as an argument, see --help for usage"
		});

		if (program.outputHelp) {
			program.outputHelp();
		}

		process.exit(1);
	}

	var appJSON;
	const appJSONPath = path.join(projPath, "app.json");
	const isExpoApp = isExpoProject(projPath);

	isExpoApp && log({ text: "Expo detected" }, programOpts.quiet);

	try {
		appJSON = require(appJSONPath);

		if (isExpoApp && !programOpts.incrementBuild) {
			appJSON = Object.assign({}, appJSON, {
				expo: Object.assign({}, appJSON.expo, {
					version: appPkg.version
				})
			});
		}
	} catch (err) {}

	var android;
	var ios;

	if (!targets.length || targets.indexOf("android") > -1) {
		android = new Promise(function(resolve, reject) {
			log({ text: "Versioning Android..." }, programOpts.quiet);

			var gradleFile;

			try {
				gradleFile = fs.readFileSync(programOpts.android, "utf8");
			} catch (err) {
				isExpoApp ||
					reject([
						{
							style: "red",
							text: "No gradle file found at " + programOpts.android
						},
						{
							style: "yellow",
							text: 'Use the "--android" option to specify the path manually'
						}
					]);
			}

			if (!programOpts.incrementBuild && !isExpoApp) {
				gradleFile = gradleFile.replace(
					/versionName (["'])(.*)["']/,
					"versionName $1" + appPkg.version + "$1"
				);
			}

			if (!programOpts.neverIncrementBuild) {
				if (isExpoApp) {
					const versionCode = dottie.get(appJSON, "expo.android.versionCode");

					appJSON = Object.assign({}, appJSON, {
						expo: Object.assign({}, appJSON.expo, {
							android: Object.assign({}, appJSON.expo.android, {
								versionCode: programOpts.setBuild
									? programOpts.setBuild
									: versionCode
									? versionCode + 1
									: 1
							})
						})
					});
				} else {
					gradleFile = gradleFile.replace(/versionCode (\d+)/, function(
						match,
						cg1
					) {
						const newVersionCodeNumber = programOpts.setBuild
							? programOpts.setBuild
							: parseInt(cg1, 10) + 1;

						return "versionCode " + newVersionCodeNumber;
					});
				}
			}

			if (isExpoApp) {
				fs.writeFileSync(appJSONPath, JSON.stringify(appJSON, null, 2));
			} else {
				fs.writeFileSync(programOpts.android, gradleFile);
			}

			log({ text: "Android updated" }, programOpts.quiet);
			resolve();
		});
	}

	if (!targets.length || targets.indexOf("ios") > -1) {
		ios = new Promise(function(resolve, reject) {
			log({ text: "Versioning iOS..." }, programOpts.quiet);

			if (isExpoApp) {
				if (!programOpts.neverIncrementBuild) {
					const buildNumber = dottie.get(appJSON, "expo.ios.buildNumber");

					appJSON = Object.assign({}, appJSON, {
						expo: Object.assign({}, appJSON.expo, {
							ios: Object.assign({}, appJSON.expo.ios, {
								buildNumber: programOpts.setBuild
									? programOpts.setBuild.toString()
									: buildNumber && !programOpts.resetBuild
									? `${parseInt(buildNumber, 10) + 1}`
									: "1"
							})
						})
					});
				}

				fs.writeFileSync(appJSONPath, JSON.stringify(appJSON, null, 2));
			} else if (program.legacy) {
				try {
					child.execSync("xcode-select --print-path", {
						stdio: ["ignore", "ignore", "pipe"]
					});
				} catch (err) {
					reject([
						{
							style: "red",
							text: err
						},
						{
							style: "yellow",
							text: "Looks like Xcode Command Line Tools aren't installed"
						},
						{
							text: "\n  Install:\n\n    $ xcode-select --install\n"
						}
					]);

					return;
				}

				const agvtoolOpts = {
					cwd: programOpts.ios
				};

				try {
					child.execSync("agvtool what-version", agvtoolOpts);
				} catch (err) {
					const stdout = err.stdout.toString().trim();

					reject(
						stdout.indexOf("directory") > -1
							? [
									{
										style: "red",
										text: "No project folder found at " + programOpts.ios
									},
									{
										style: "yellow",
										text: 'Use the "--ios" option to specify the path manually'
									}
							  ]
							: [
									{
										style: "red",
										text: stdout
									}
							  ]
					);

					return;
				}

				if (!programOpts.incrementBuild) {
					child.spawnSync(
						"agvtool",
						["new-marketing-version", appPkg.version],
						agvtoolOpts
					);
				}

				if (!programOpts.neverIncrementBuild) {
					if (programOpts.resetBuild) {
						child.execSync("agvtool new-version -all 1", agvtoolOpts);
					} else {
						child.execSync("agvtool next-version -all", agvtoolOpts);
					}

					if (programOpts.setBuild) {
						child.execSync(
							`agvtool new-version -all ${program.setBuild}`,
							agvtoolOpts
						);
					}
				}
			} else {
				// Find any folder ending in .xcodeproj
				const xcodeProjects = fs
					.readdirSync(programOpts.ios)
					.filter(file => /\.xcodeproj$/i.test(file));

				if (xcodeProjects.length < 1) {
					throw new Error(`Xcode project not found in "${programOpts.ios}"`);
				}

				const projectFolder = path.join(programOpts.ios, xcodeProjects[0]);
				const xcode = Xcode.open(path.join(projectFolder, "project.pbxproj"));
				const plistFilenames = getPlistFilenames(xcode);

				xcode.document.projects.forEach(project => {
					!programOpts.neverIncrementBuild &&
						project.targets.filter(Boolean).forEach(target => {
							target.buildConfigurationsList.buildConfigurations.forEach(
								config => {
									if (target.name === appPkg.name) {
										var CURRENT_PROJECT_VERSION = 1;

										if (!programOpts.resetBuild) {
											CURRENT_PROJECT_VERSION =
												parseInt(
													config.ast.value
														.get("buildSettings")
														.get("CURRENT_PROJECT_VERSION").text,
													10
												) + 1;
										}

										if (programOpts.setBuild) {
											CURRENT_PROJECT_VERSION = programOpts.setBuild;
										}

										config.patch({
											buildSettings: {
												CURRENT_PROJECT_VERSION
											}
										});
									}
								}
							);
						});

					const plistFiles = plistFilenames.map(filename => {
						return fs.readFileSync(
							path.join(programOpts.ios, filename),
							"utf8"
						);
					});

					const parsedPlistFiles = plistFiles.map(file => {
						return plist.parse(file);
					});

					parsedPlistFiles.forEach((json, index) => {
						fs.writeFileSync(
							path.join(programOpts.ios, plistFilenames[index]),
							plist.build(
								Object.assign(
									{},
									json,
									!programOpts.incrementBuild
										? {
												CFBundleShortVersionString: appPkg.version
										  }
										: {},
									!programOpts.neverIncrementBuild
										? Object.assign(
												{},
												{
													CFBundleVersion: `${
														programOpts.resetBuild
															? 1
															: parseInt(json.CFBundleVersion, 10) + 1
													}`
												},
												programOpts.setBuild
													? {
															CFBundleVersion: programOpts.setBuild.toString()
													  }
													: {}
										  )
										: {}
								)
							)
						);
					});

					plistFilenames.forEach((filename, index) => {
						const indent = detectIndent(plistFiles[index]);

						fs.writeFileSync(
							path.join(programOpts.ios, filename),
							stripIndents`
							<?xml version="1.0" encoding="UTF-8"?>
							<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
							<plist version="1.0">` +
								"\n" +
								beautify(
									fs
										.readFileSync(path.join(programOpts.ios, filename), "utf8")
										.match(/<dict>[\s\S]*<\/dict>/)[0],
									Object.assign(
										{ end_with_newline: true },
										indent.type === "tab"
											? { indent_with_tabs: true }
											: { indent_size: indent.amount }
									)
								) +
								stripIndents`
							</plist>` +
								"\n"
						);
					});
				});

				xcode.save();
			}

			log({ text: "iOS updated" }, programOpts.quiet);
			resolve();
		});
	}

	return pSettle([android, ios].filter(Boolean))
		.then(function(result) {
			const errs = result
				.filter(function(item) {
					return item.isRejected;
				})
				.map(function(item) {
					return item.reason;
				});

			if (errs.length) {
				errs
					.reduce(function(a, b) {
						return a.concat(b);
					}, [])
					.forEach(function(err) {
						if (program.outputHelp) {
							log(
								Object.assign({ style: "red", text: err.toString() }, err),
								programOpts.quiet
							);
						}
					});

				if (program.outputHelp) {
					program.outputHelp();
				}

				throw errs
					.map(function(errGrp, index) {
						return errGrp
							.map(function(err) {
								return err.text;
							})
							.join(", ");
					})
					.join("; ");
			}

			const gitCmdOpts = {
				cwd: projPath
			};

			if (
				programOpts.amend ||
				(process.env.npm_lifecycle_event &&
					process.env.npm_lifecycle_event.indexOf("version") > -1 &&
					!programOpts.neverAmend)
			) {
				const latestTag =
					(programOpts.amend ||
						process.env.npm_config_git_tag_version ||
						process.env.npm_config_version_git_tag) &&
					!programOpts.skipTag &&
					semver.valid(
						semver.coerce(
							child
								.execSync("git log -1 --pretty=%s", gitCmdOpts)
								.toString()
								.trim()
						)
					) &&
					child
						.execSync("git describe --exact-match HEAD", gitCmdOpts)
						.toString()
						.trim();

				log({ text: "Amending..." }, programOpts.quiet);

				switch (process.env.npm_lifecycle_event) {
					case "version":
						child.spawnSync(
							"git",
							["add"].concat(
								isExpoApp ? appJSONPath : [programOpts.android, programOpts.ios]
							),
							gitCmdOpts
						);

						break;

					case "postversion":
					default:
						child.execSync("git commit -a --amend --no-edit", gitCmdOpts);

						if (latestTag) {
							log({ text: "Adjusting Git tag..." }, programOpts.quiet);

							child.execSync(
								`git tag -af ${latestTag} -m ${latestTag}`,
								gitCmdOpts
							);
						}
				}
			}

			log(
				{
					style: "green",
					text: "Done"
				},
				programOpts.quiet
			);

			if (programOpts.neverAmend) {
				return true;
			}

			return child.execSync("git log -1 --pretty=%H", gitCmdOpts).toString();
		})
		.catch(function(err) {
			if (process.env.RNV_ENV === "ava") {
				console.error(err);
			}

			log({
				style: "red",
				text: "Done, with errors."
			});

			process.exit(1);
		});
}
1318888
function mergeCommands(commands) {
  const cmds = filterCommands(commands);
  if (cmds.length === 0) {
    throw new Error('Expected at least one non-empty command');
  } else if (cmds.length === 1) {
    return cmds[0];
  } else {
    // Quote the arguments in each command and join them all using &&.
    const script = cmds.map(quote).join(' && ');
    return ['/bin/sh', '-c', script];
  }
}
259931
function addValidCommands(command) {
		var result = false
		if (command && commands.indexOf(command) != -1) {
			result = true
			commandQueue.push(command)
		}
		return result
	}
539029
function registerUnknownCommands (cli, options) {
  cli.on('command:*', async () => {
    const { args, options: commandoptions } = cli

    logger.debug('global_options', options)
    logger.debug('cli_options', commandoptions)
    logger.debug('cli_args', args)

    const [commandName] = args
    const sourceDir = args[1] ? path.resolve(args[1]) : pwd
    const inferredUserDocsDirectory = await inferUserDocsDirectory(pwd)
    logger.developer('inferredUserDocsDirectory', inferredUserDocsDirectory)
    logger.developer('sourceDir', sourceDir)

    if (inferredUserDocsDirectory && sourceDir !== inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      console.log()
      logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
      logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)
      console.log()
      process.exit(1)
    }

    if (!inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      process.exit(1)
    }

    logger.debug('Custom command', chalk.cyan(commandName))
    CLI({
      async beforeParse (subCli) {
        const app = createApp({
          sourceDir: sourceDir,
          ...options,
          ...commandoptions
        })
        await app.process()
        app.pluginAPI.applySyncOption('extendCli', subCli, app)
        console.log()
      },
      async afterParse (subCli) {
        if (!subCli.matchedCommand) {
          logUnknownCommand(subCli)
          console.log()
        }
      }
    })
  })
}
1356004
function addCommandOnCmdEditor (config) {

	var cmd_name = null;

	var promise = inquirer.prompt([{
		type: 'input',
		name: 'cmdName',
		message: 'What is name of a command (e.g. setMotorPower) ?',
		validate: function (value) {
			if (value.length == 0) return true;
			if (config.commands[value] != null) return 'This command name has already existed.';
			if (!value.match(/^[A-Za-z0-9_]+$/)) return 'Available characters for argument name: A-Z, a-z, 0-9, underscore.\n\
Or, if you want to cancel, please press the enter key left empty.';
			return true;
		}

	}]).then(function (answer) {

		cmd_name = answer.cmdName || null;
		if (cmd_name == null || cmd_name.length == 0) {
			return null;
		}

		return inquirer.prompt([{
			type: 'input',
			name: 'cmdDesc',
			message: 'What is description of ' + cmd_name + ' command ?'
		}]);


	}).then(function (answer) {

		if (cmd_name == null) return false;

		var commands = config.commands || {};
		commands[cmd_name] = {
			description: answer.cmdDesc || null,
			args: {}
		};

		// Done
		console.log(colors.bold.green('This command has been created: ' + cmd_name));

		// Save to the commands file
		console.log('\nWriting to ' + process.cwd() + '/' + COMMANDS_FILENAME);
		fs.writeFileSync(COMMANDS_FILENAME, JSON.stringify(config.commands));
		console.log('Writing has been completed.\n\n');
		return true;

	});

	return promise;

}
987673
function process(parent, index, commands) {
    var cmd = commands[index],
        ret;

    switch (cmd.value[0].type) {
        case ConkittyTypes.TEMPLATE_NAME:
            ret = processCall(parent, false, cmd);
            break;

        case ConkittyTypes.COMMAND_NAME:
            switch (cmd.value[0].value) {
                case 'ATTR':
                    ret = processAttr(parent, true, cmd);
                    break;

                case 'CALL':
                    ret = processCall(parent, true, cmd, commands[index + 1]);
                    break;

                case 'CHOOSE':
                    ret = processChoose(parent, cmd);
                    break;

                case 'EACH':
                    ret = processEach(parent, cmd, commands[index + 1]);
                    break;

                case 'EXPOSE':
                    ret = processExpose(parent, cmd);
                    break;

                case 'JS':
                    ret = processJS(parent, cmd);
                    break;

                case 'MEM':
                    ret = processMem(parent, cmd);
                    break;

                case 'PAYLOAD':
                    ret = processPayload(parent, cmd);
                    break;

                case 'SET':
                    ret = processSet(parent, cmd);
                    break;

                case 'TEST':
                    ret = processTest(parent, cmd);
                    break;

                case 'TRIGGER':
                    ret = processTrigger(parent, cmd);
                    break;

                case 'WITH':
                    ret = processWith(parent, cmd, commands[index + 1]);
                    break;

                default:
                    throw new ConkittyErrors.InconsistentCommand(cmd.value[0]);
            }

            break;

        case ConkittyTypes.VARIABLE:
            ret = processVariable(parent, cmd);
            break;

        case ConkittyTypes.JAVASCRIPT:
            ret = processJavascript(parent, cmd);
            break;

        case ConkittyTypes.STRING:
            ret = processString(parent, cmd);
            break;

        case ConkittyTypes.CSS:
            ret = processElement(parent, cmd);
            break;

        case ConkittyTypes.ATTR:
            ret = processAttr(parent, false, cmd);
            break;

        case ConkittyTypes.INCLUDE:
            ret = processInclude(parent, cmd);
            break;

        case ConkittyTypes.NODE_APPENDER:
            ret = processAppender(parent, cmd);
            break;

        default:
            throw new ConkittyErrors.InconsistentCommand(cmd.value[0]);
    }

    return index + ret;
}
361299
function Command(command, options) {
  var previousPath;

  this.command = command;

  // We're on Windows if `process.platform` starts with "win", i.e. "win32".
  this.isWindows = (process.platform.lastIndexOf('win') === 0);

  // the cwd and environment of the command are the same as the main node
  // process by default.
  this.options = defaults(options || {}, {
    cwd: process.cwd(),
    env: process.env,
    verbosity: (options && options.silent) ? 1 : 2,
    usePowerShell: false
  });

  // include node_modules/.bin on the path when we execute the command.
  previousPath = this.options.env.PATH;
  this.options.env.PATH = path.join(this.options.cwd, 'node_modules', '.bin');
  this.options.env.PATH += path.delimiter;
  this.options.env.PATH += previousPath;
}
1310263
function wizardSetup (program) {
  const welcome = multiline.stripIndent(function () { /*
        Welcome to the Electron-Windows-Store tool!

        This tool will assist you with turning your Electron app into
        a swanky Windows Store app.

        We need to know some settings. We will ask you only once and store
        your answers in your profile folder in a .electron-windows-store
        file.

    */
  })
  const complete = multiline.stripIndent(function () { /*

        Setup complete, moving on to package your app!

    */
  })

  let questions = [
    {
      name: 'desktopConverter',
      type: 'input',
      message: 'Please enter the path to your Desktop App Converter (DesktopAppConverter.ps1): ',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.desktopConverter)
    },
    {
      name: 'expandedBaseImage',
      type: 'input',
      message: 'Please enter the path to your Expanded Base Image: ',
      default: 'C:\\ProgramData\\Microsoft\\Windows\\Images\\BaseImage-14316\\',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.expandedBaseImage)
    },
    {
      name: 'devCert',
      type: 'input',
      message: 'Please enter the path to your development PFX certficate: ',
      default: null,
      when: () => (!dotfile.get().makeCertificate || !program.devCert)
    },
    {
      name: 'publisher',
      type: 'input',
      message: 'Please enter your publisher identity: ',
      default: 'CN=developmentca',
      when: () => (!program.publisher)
    },
    {
      name: 'windowsKit',
      type: 'input',
      message: "Please enter the location of your Windows Kit's bin folder: ",
      default: utils.getDefaultWindowsKitLocation(),
      when: () => (!program.windowsKit)
    }
  ]

  if (!program.isModuleUse) {
    utils.log(welcome)
  }

  // Remove the Desktop Converter Questions if not installed
  if (program.didInstallDesktopAppConverter === false) {
    questions = questions.slice(3)
  }

  if (program.isModuleUse) {
    program.windowsKit = program.windowsKit || utils.getDefaultWindowsKitLocation()

    return Promise.resolve(program)
  }

  return inquirer.prompt(questions)
    .then((answers) => {
      dotfile.set({
        desktopConverter: answers.desktopConverter || false,
        expandedBaseImage: answers.expandedBaseImage || false,
        devCert: answers.devCert,
        publisher: answers.publisher,
        windowsKit: answers.windowsKit,
        makeCertificate: dotfile.get().makeCertificate
      })

      program.desktopConverter = answers.desktopConverter
      program.expandedBaseImage = answers.expandedBaseImage
      program.devCert = answers.devCert
      program.publisher = answers.publisher
      program.windowsKit = answers.windowsKit

      if (program.makeCertificate) {
        utils.log(chalk.bold.green('Creating Certficate'))
        let publisher = dotfile.get().publisher.split('=')[1]
        let certFolder = path.join(process.env.APPDATA, 'electron-windows-store', publisher)

        return sign.makeCert({ publisherName: publisher, certFilePath: certFolder, program: program })
          .then(pfxFile => {
            utils.log('Created and installed certificate:')
            utils.log(pfxFile)
            dotfile.set({ devCert: pfxFile })
          })
      }

      utils.log(complete)
    })
}
1034838
function(cmd) {
        cmd = cmd.replace(/\\ /g, '___save___');
        var split = cmd.split(' ');
        split.forEach((p, i) => split[i] = p.replace(/___save___/g, '\ '));
        var parts = [];
        var i = 0;
        while (i < split.length) {
            var part = split[i];
            var first = part[0];
            if (first == "'" || first == '"') {
                part = part.substr(1);
                var j = i + 1;
                while (j < split.length) {
                    part += ' ' + split[j];
                    var last = part[part.length - 1];
                    if (last == first) {
                        part = part.substr(0, part.length - 1);
                        i = j;
                        break;
                    }

                    j++;
                }
            }

            if (part == '{config}') {
                part = JSON.stringify($$config);
            }

            parts.push(part);
            i++;
        }

        parts[0] = path.resolve(parts[0]);
        return parts;
    }
635176
function getKeyBindings(command) {
        var bindings    = [],
            commandID   = "";

        if (!command) {
            console.error("getKeyBindings(): missing required parameter: command");
            return [];
        }

        if (typeof (command) === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        bindings = _commandMap[commandID];
        return bindings || [];
    }