Sha256: f5bb636b6521a33a9114c77c38bcffc27be4cd06230441f61454cc169d997f51

Contents?: true

Size: 1.14 KB

Versions: 45

Compression:

Stored size: 1.14 KB

Contents

var common = require('./common');

//@
//@ ### set(options)
//@ Available options:
//@
//@ + `+/-e`: exit upon error (`config.fatal`)
//@ + `+/-v`: verbose: show all commands (`config.verbose`)
//@
//@ Examples:
//@
//@ ```javascript
//@ set('-e'); // exit upon first error
//@ set('+e'); // this undoes a "set('-e')"
//@ ```
//@
//@ Sets global configuration variables
function _set(options) {
  if (!options) {
    var args = [].slice.call(arguments, 0);
    if (args.length < 2)
      common.error('must provide an argument');
    options = args[1];
  }
  var negate = (options[0] === '+');
  if (negate) {
    options = '-' + options.slice(1); // parseOptions needs a '-' prefix
  }
  options = common.parseOptions(options, {
    'e': 'fatal',
    'v': 'verbose'
  });

  var key;
  if (negate) {
    for (key in options)
      options[key] = !options[key];
  }

  for (key in options) {
    // Only change the global config if `negate` is false and the option is true
    // or if `negate` is true and the option is false (aka negate !== option)
    if (negate !== options[key]) {
      common.config[key] = options[key];
    }
  }
  return;
}
module.exports = _set;

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.21.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.20.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.19.1 node_modules/shelljs/src/set.js
govuk_publishing_components-17.19.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.18.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.17.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.16.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.15.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.14.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.13.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.12.2 node_modules/shelljs/src/set.js
govuk_publishing_components-17.12.1 node_modules/shelljs/src/set.js
govuk_publishing_components-17.12.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.11.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.10.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.9.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.8.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.7.0 node_modules/shelljs/src/set.js
govuk_publishing_components-17.6.1 node_modules/shelljs/src/set.js