Skip to content

Instantly share code, notes, and snippets.

@MadLittleMods
Created October 27, 2016 05:16
Show Gist options
  • Save MadLittleMods/018089c00bc9e0852112e5740cfc9a5c to your computer and use it in GitHub Desktop.
Save MadLittleMods/018089c00bc9e0852112e5740cfc9a5c to your computer and use it in GitHub Desktop.
'use strict';
var argv = require('yargs').argv;
// See https://github.com/yargs/yargs/issues/402
// This will shim the `.option({ position: x })` that was in `nomnom` but we are now using `yargs`
var shimPositionOption = function(optionsOpts) {
var opts = Object.assign({}, optionsOpts);
if(opts.hasOwnProperty('position') && opts.position < argv._.length) {
opts.default = opts.default || argv._[opts.position];
}
return opts;
}
module.exports = shimPositionOption;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment