How to use the minimist function in minimist

To help you get started, we’ve selected a few minimist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / prepack / scripts / test262.js View on Github external
function masterArgsParse(): MasterProgramArgs {
  let { _: _paths, verbose, timeout, statusFile, testDir } = minimist(process.argv.slice(2), {
    string: ["statusFile", "testDir"],
    boolean: ["verbose"],
    default: {
      testDir: ["..", "test", "test262"].join(path.sep),
      verbose: process.stdout instanceof tty.WriteStream ? false : true,
      statusFile: "",
      timeout: 10,
    },
  });

  // Test paths can be provided as "built-ins/Array", "language/statements/class", etc.
  let paths = _paths.map(p => path.join("test", p));
  if (typeof verbose !== "boolean") {
    throw new Error("verbose must be a boolean (either --verbose or not)");
  }
  if (typeof timeout !== "number") {
github catamphetamine / webapp / code / common / configuration.js View on Github external
// allows overriding the default configuration 
// using `[project_folder]/configuration.js` file
// (if the file exists)
const specific_configuration_path = path.resolve(__dirname, '../../configuration.js')
if (fs.existsSync(specific_configuration_path))
{
	const specific_configuration = require(specific_configuration_path)
	Object.extend(configuration, specific_configuration)
}

export default configuration

// можно будет использовать этот файл в shell'овых скриптах
// (команда: node configuration.coffee --path="...")

const process_arguments = minimist(process.argv.slice(2))

if (process_arguments.path)
{
	console.log(Object.path(configuration, process_arguments.path))
	process.exit()
}
github mgrip / startd / packages / startd-server / src / index.js View on Github external
//@flow

import webpack from "webpack";
import path from "path";
import fs from "fs";
import chalk from "chalk";
import minimist from "minimist";
import findUp from "find-up";
import logger from "./logger";
import config from "./webpack.config.js";
import { spawn } from "child_process"

const {
  _: [inputPath],
  middleware
} = minimist(process.argv.slice(2));

if (typeof inputPath !== "string") {
  logger.error("You must provide a valid path to your root App component");
  process.exit(1);
}
// $FlowFixMe - for some reason flow isn't picking up the process.exit above
const appPath = path.resolve(process.cwd(), inputPath);
if (!fs.existsSync(appPath)) {
  logger.error(`${appPath} is not a valid filepath 😿`);
  process.exit(1);
}

let middlewarePath;
if (middleware) {
  middlewarePath = path.resolve(process.cwd(), middleware);
  if (!fs.existsSync(middlewarePath)) {
github zeit / pkg / lib / index.js View on Github external
export async function exec (argv2) { // eslint-disable-line complexity
  const argv = minimist(argv2, {
    boolean: [ 'b', 'build', 'bytecode', 'd', 'debug',
      'h', 'help', 'public', 'v', 'version' ],
    string: [ '_', 'c', 'config', 'o', 'options', 'output',
      'outdir', 'out-dir', 'out-path', 'public-packages',
      't', 'target', 'targets' ],
    default: { bytecode: true }
  });

  if (argv.h || argv.help) {
    help();
    return;
  }

  // version

  if (argv.v || argv.version) {
github atolye15 / web-starter-kit / gulp / utils / parseArguments.js View on Github external
import minimist from 'minimist';

const argv = minimist(process.argv.slice(2));

// eslint-disable-next-line import/prefer-default-export
export const isProduction = argv.prod;
github mermaid-js / mermaid / lib / cli.js View on Github external
Cli.prototype.parse = function (argv, next) {
  this.errors = [] // clear errors
  var options = parseArgs(argv, this.options)
  if (options.version) {
    this.message = '' + pkg.version
    next(null, this.message)
  } else if (options.help) {
    this.message = this.helpMessage.join('\n')
    next(null, this.message)
  } else {
    options.files = options._

    if (!options.files.length) {
      this.errors.push(new Error('You must specify at least one source file.'))
    }

    // ensure that parameter-expecting options have parameters
    ;['outputDir', 'outputSuffix', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function (i) {
      if (typeof options[i] !== 'undefined') {
github facebook / prepack / scripts / test262-runner.js View on Github external
function workerArgsParse(): WorkerProgramArgs {
  let parsedArgs = minimist(process.argv.slice(2), {
    default: {
      timeout: 10,
      relativeTestPath: "/../test/test262",
    },
  });
  if (typeof parsedArgs.timeout !== "number") {
    throw new ArgsParseError("timeout must be a number (in seconds) (--timeout 10)");
  }
  if (typeof parsedArgs.relativeTestPath !== "string") {
    throw new ArgsParseError("relativeTestPath must be a string (--relativeTestPath /../test/test262)");
  }
  return new WorkerProgramArgs(parsedArgs.timeout, parsedArgs.relativeTestPath);
}
github insin / nwb / src / commands / react.js View on Github external
if (error instanceof UserError) {
    console.error(red(error.message))
  }
  else if (error instanceof ConfigValidationError) {
    error.report.log()
  }
  else {
    console.error(red(`Error running command: ${error.message}`))
    if (error.stack) {
      console.error(error.stack)
    }
  }
  process.exit(1)
}

let args = parseArgs(process.argv.slice(3), {
  alias: {
    c: 'config',
    p: 'plugins',
  }
})

let command = args._[0]

if (!command || /^h(elp)?$/.test(command)) {
  console.log(`Usage: ${cmd('nwb react')} ${req('(run|build)')} ${opt('[options]')}

Options:
  ${opt('-c, --config')}       config file to use ${opt(`[default: ${CONFIG_FILE_NAME}]`)}
  ${opt('-p, --plugins')}      a comma-separated list of nwb plugins to use

Commands:
github shwilliam / vue-scrollin / build / rollup.config.js View on Github external
import vue from 'rollup-plugin-vue'
import buble from 'rollup-plugin-buble'
import uglify from 'rollup-plugin-uglify-es'
import minimist from 'minimist'

const argv = minimist(process.argv.slice(2))

const config = {
  input: 'src/index.js',
  output: {
    name: 'VScrollin',
    exports: 'named'
  },
  plugins: [
    vue({
      css: true,
      compileTemplate: true
    }),
    buble()
  ]
}
github runtools / run / packages / cli / src / bin / initialize.js View on Github external
(async function() {
  showIntro(require('../../package.json'));

  const pkgDir = getPackageDirOption(false);

  const argv = minimist(process.argv.slice(2), {
    string: [
      'type'
    ],
    boolean: [
      'yarn'
    ],
    default: {
      'yarn': null
    }
  });

  const type = argv.type || argv._[0];

  const yarn = argv['yarn'];

  const code = await initialize({ pkgDir, type, yarn });