aboutsummaryrefslogtreecommitdiff
path: root/_mint/node_modules/editorconfig/src/cli.js
blob: 0589b0c61fc81f4602964ec7d3da7c6b063c14c6 (plain)
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
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:no-console
var commander_1 = __importDefault(require("commander"));
var editorconfig = __importStar(require("./"));
var package_json_1 = __importDefault(require("../package.json"));
function cli(args) {
    commander_1.default.version('EditorConfig Node.js Core Version ' + package_json_1.default.version);
    commander_1.default
        .usage([
        '[OPTIONS] FILEPATH1 [FILEPATH2 FILEPATH3 ...]',
        commander_1.default._version,
        'FILEPATH can be a hyphen (-) if you want path(s) to be read from stdin.',
    ].join('\n\n  '))
        .option('-f <path>', 'Specify conf filename other than \'.editorconfig\'')
        .option('-b <version>', 'Specify version (used by devs to test compatibility)')
        .option('-v, --version', 'Display version information')
        .parse(args);
    // Throw away the native -V flag in lieu of the one we've manually specified
    // to adhere to testing requirements
    commander_1.default.options.shift();
    var files = commander_1.default.args;
    if (!files.length) {
        commander_1.default.help();
    }
    files
        .map(function (filePath) { return editorconfig.parse(filePath, {
        config: commander_1.default.F,
        version: commander_1.default.B,
    }); })
        .forEach(function (parsing, i, _a) {
        var length = _a.length;
        parsing.then(function (parsed) {
            if (length > 1) {
                console.log("[" + files[i] + "]");
            }
            Object.keys(parsed).forEach(function (key) {
                console.log(key + "=" + parsed[key]);
            });
        });
    });
}
exports.default = cli;