All files args.js

100% Statements 24/24
100% Branches 15/15
100% Functions 3/3
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102            14x 14x 14x                                                                     14x         14x                       14x   14x   14x     14x   22x 22x     22x 8x     22x 22x 22x   22x 1x     22x 21x     22x     14x 14x     14x          
/*
Copyright (c) 2013, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
 
const nopt = require('nopt');
const chalk = require('chalk');
const knownOptions = {
    angularCli: Boolean,
    clarificationsFile: require('path'),
    color: Boolean,
    csv: Boolean,
    csvComponentPrefix: String,
    customFormat: {},
    customPath: require('path'),
    development: Boolean,
    direct: Boolean,
    excludeLicenses: String,
    excludePackages: String,
    excludePackagesStartingWith: String,
    excludePrivatePackages: Boolean,
    failOn: String,
    files: require('path'),
    help: Boolean,
    includeLicenses: String,
    includePackages: String,
    json: Boolean,
    limitAttributes: String,
    markdown: Boolean,
    nopeer: Boolean,
    onlyAllow: String,
    onlyunknownOpts: Boolean,
    out: require('path'),
    plainVertical: Boolean,
    production: Boolean,
    relativeLicensePath: Boolean,
    relativeModulePath: Boolean,
    start: String,
    summary: Boolean,
    unknownOpts: Boolean,
    version: Boolean,
};
const shortHands = {
    h: ['--help'],
    v: ['--version'],
};
 
const getParsedArguments = function getParsedArguments(args) {
    // nopt returns an object looking like this, if you pass the params '--one --two here there -- --three --four':
    //
    // parsed {
    //   one: true,
    //   two: true,
    //   argv: {
    //     remain: [ 'here', 'there', '--three', '--four' ],
    //     cooked: [ '--one', '--two', 'here', 'there', '--', '--three', '--four' ], // contains the expanded shorthand options
    //     original: [ '--one', '--two', 'here', 'there', '--', '--three', '--four' ]
    //   }
    // }
    const parsed = nopt(knownOptions, shortHands, args || process.argv);
 
    delete parsed.argv;
 
    return parsed;
};
 
const setDefaults = function setDefaults(parsed = {}) {
    /*istanbul ignore else*/
    if (parsed.color == null) {
        parsed.color = chalk.supportsColor;
    }
 
    if (parsed.json || parsed.markdown || parsed.csv) {
        parsed.color = false;
    }
 
    parsed.start = parsed.start || process.cwd();
    parsed.relativeLicensePath = Boolean(parsed.relativeLicensePath);
    parsed.relativeModulePath = Boolean(parsed.relativeModulePath);
 
    if (parsed.direct === true) {
        parsed.direct = 0;
    }
 
    if (typeof parsed.direct !== 'number') {
        parsed.direct = Infinity;
    }
 
    return parsed;
};
 
const parse = function parse(args) {
    return setDefaults(getParsedArguments(args));
};
 
module.exports = {
    knownOptions: knownOptions,
    parse: parse,
    setDefaults: setDefaults,
};