How to use the yargs.argv._ function in yargs

To help you get started, we’ve selected a few yargs 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 ClintH / gtbg / app.js View on Github external
config.init(); // Load from config
config.layerArgs(argv); // Add in commandline overrides
presets.init();

if (!sox.exists()) {
  sox.install();
} else {
	// Sox is installed
	if (argv._.length === 0) { // No command
		var ui = require("./ui");
		ui(function(complete) {
			start(complete);
		});
	} else {
			var opt = argv._[0];
			if (opt == "info") {
				start({});
				return;
			}

			// Some command
			// Load preset
			var preset = presets.get(opt);
			if (preset === null) {
				console.log(chalk.red("Preset '" + opt + "' not found."));
				console.log("Try: " + presets.getKeys().join(", "));
			} else {
				// Got a valid preset
				start(preset);
			}
	}
github AlCalzone / node-tradfri-client / maintenance / release.ts View on Github external
if (!argv.dry) fail(colors.red("Cannot continue, the local branch is behind the remote changes!"));
	else console.log(colors.red("This is a dry run. The full run would fail due to the local branch being behind\n"));
} else if (/Your branch is up\-to\-date/.test(gitStatus) || /Your branch is ahead/.test(gitStatus)) {
	// all good
	console.log(colors.green("git status is good - I can continue..."));
}

const releaseTypes = ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];

const releaseType = argv._[0] || "patch";
let newVersion = releaseType;
const oldVersion = pack.version as string;
if (releaseTypes.indexOf(releaseType) > -1) {
	if (releaseType.startsWith("pre") && argv._.length >= 2) {
		// increment to pre-release with an additional prerelease string
		newVersion = semver.inc(oldVersion, releaseType, argv._[1]);
	} else {
		newVersion = semver.inc(oldVersion, releaseType);
	}
	console.log(`bumping version ${colors.blue(oldVersion)} to ${colors.gray(releaseType)} version ${colors.green(newVersion)}\n`);
} else {
	// increment to specific version
	newVersion = semver.clean(newVersion);
	if (newVersion == null) {
		fail(`invalid version string "${newVersion}"`);
	} else {
		// valid version string => check if its actually newer
		if (!semver.gt(newVersion, pack.version)) {
			fail(`new version ${newVersion} is NOT > than package.json version ${pack.version}`);
		}
		// if (!semver.gt(newVersion, ioPack.common.version)) {
		// 	fail(`new version ${newVersion} is NOT > than io-package.json version ${ioPack.common.version}`);
github bnetter / traildust / app.js View on Github external
return new Promise((resolve, reject) => {
    let path = argv.path;

    // If `path` is not set, use the first argument (if it exists)
    if (_.isUndefined(path) && _.isArray(argv._) && argv._.length > 0) {
      path = argv._[0];
    }

    if (!_.isUndefined(path)) {
      return resolve(path);
    }

    // Otherwise, ask for a proper path
    return inquirer.prompt([ question ])
      .then((answers) => resolve(answers.path))
      .catch((err) => reject(err));
  });
}
github backstrokeapp / server / frontend / gulpfile.js View on Github external
browserify: function() {
    var bundler = browserify('./src/js/index.js', {
      debug: !production,
      cache: {},
      paths: ['./node_modules', './src/js'],
    });
    bundler.transform(babelify)
    bundler.transform(envify)
    // determine if we're doing a build
    // and if so, bypass the livereload
    var build = argv._.length ? argv._[0] === 'build' : false;
    if (watch) {
      bundler = watchify(bundler);
    }
    var rebundle = function() {
      return bundler.bundle()
        .on('error', handleError('Browserify'))
        .pipe(source('build.js'))
        .pipe(gulpif(production, buffer()))
        .pipe(gulpif(production, uglify()))
        .pipe(gulp.dest('build/js/'));
    };
    bundler.on('update', rebundle);
    return rebundle();
  },
};
github freeCodeCamp / freeCodeCamp / tools / scripts / lint / index.js View on Github external
const lintRules = require('./.markdownlintrc');
const linter = require('./linter');
const argv = require('yargs').argv;

const isMDRE = /.*\.md$/;

const lint = linter(lintRules);

const files = argv._.filter(arg => isMDRE.test(arg));
files.forEach(path => lint({ path: path }));

module.exports = lint;
github yargs / yargs / example / nonopt.js View on Github external
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
github caryll / typefaceSXS / index.js View on Github external
"use strict";

const finalhandler = require('finalhandler')
const http = require('http')
const serveStatic = require('serve-static')
const path = require('path')
const fs = require('fs-extra')
const url = require('url')
const argv = require('yargs').argv;
const toml = require('toml');
const concat = require('concat-stream');
const opn = require('opn');

if (!argv._[0]) { process.exit(1); }

const configPath = argv._[0];
const configDir = path.dirname(configPath);
const publicDir = path.join(argv.d || configDir, ".typeSXS_public");

fs.createReadStream(configPath, 'utf8').pipe(concat(function (data) {
	const config = toml.parse(data.replace(/\ufeff/g, ''));

	if (!config.typefaces) { throw "[typefaces] not defined." }
	if (!config.articles) { throw "[articles] not defined." }
	if (!config.styles) { throw "[styles] not defined." }
	if (!config.samples) { throw "[samples] not defined." }
	if (!config.features) { throw "[features] not defined." }

	fs.copySync(path.join(__dirname, "public"), publicDir);

	let css = '';
	let json = {
github hsubox76 / petty-af / src / index.js View on Github external
async function main() {
    const files = argv._;
    files.forEach(pettifyFile);
}
github elastic / kibana / x-pack / dev-tools / api_debug / index.js View on Github external
export function apiDebug() {
  const [ requestType ] = argv._;

  if (argv.help || !requestType) {
    showHelp();
    return;
  }

  requestFromApi(argv, requestType);
}
github ev3dev / ev3dev-lang / autogen / autogen.js View on Github external
function getTargetFileInfo() {
    var pathCandidates = argv._.concat(process.cwd());

    var configFilePath = pathCandidates.map(function(possiblePath) {
        var stat = fs.statSync(possiblePath);

        if(stat.isFile())
            return path.resolve(possiblePath);
        else if (stat.isDirectory())
            return path.resolve(possiblePath, config.defaultConfigFileName);
        else
            return null;

    }).filter(function(configPath) {
        return !!configPath && fs.existsSync(configPath);
    })[0];

    if(!configFilePath)