How to use optionator - 3 common examples

To help you get started, we’ve selected a few optionator 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 rizowski / eslint-watch / src / options.js View on Github external
option: 'clear',
    type: 'Boolean',
    description: 'Clear terminal when running lint',
  },
  {
    option: 'esw-version',
    type: 'Boolean',
    description: "Prints Eslint-Watch's Version",
  },
];

const eslintOptions = getOptions();
const newOptions = _.union(myOptions, eslintOptions);
settings.options = newOptions;

export default optionator(settings);
github riot / cli / src / index.js View on Github external
import { basename, dirname, extname, join, relative, resolve } from 'path'
import { log, logError } from './logger'
import compile from './compile'
import compose from 'cumpa'
import glob from 'glob'
import help from './help'
import optionatorFactory from 'optionator'
import options from './options'
import pkg from '../package.json'
import { statSync } from 'fs'
import watch from './watch'

const optionator = optionatorFactory(options)
const isJsFilePath = path => path.slice(-3) === '.js'

/**
 * Map the user options to valid rollup options
 * @param   {string} input - source file path
 * @param   {string} userInputPath - path provided by the user
 * @param   {Object} options - user options
 * @returns {Object} RollupOptions object
 */
export function mapOptions(input, userInputPath, options) {
  const componentName = basename(input, extname(input))

  return {
    input,
    sourcemap: options.sourcemap,
    watch: options.watch,
github rizowski / eslint-watch / src / cli / options.js View on Github external
createOptions(eswOptions, eslintOptions = []) {
    const mergedOptions = unionwith(eswOptions, eslintOptions, areEqual);
    logger.debug(mergedOptions);
    const opsor = optionator({ ...settings, options: mergedOptions });

    return {
      helpText: opsor.generateHelp(),
      parse(rawArgs) {
        const options = opsor.parse(rawArgs, { slice: 0 });
        const dirs = options._;

        if (dirs.length === 0) {
          dirs.push(path.resolve('.'));
        }

        options._ = dirs;

        return options;
      },
    };

optionator

option parsing and help generation

MIT
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis

Popular optionator functions