UNPKG

1.26 kBPlain TextView Raw
1#!/usr/bin/env node
2
3var path = require("path");
4var program = require("commander");
5var Promise = require("bluebird");
6
7var editorconfig = require("../editorconfig");
8var package = require("../package.json");
9
10program.version("EditorConfig Node.js Core Version " + package.version);
11
12program
13 .usage([
14 "[OPTIONS] FILEPATH1 [FILEPATH2 FILEPATH3 ...]",
15 program._version,
16 "FILEPATH can be a hyphen (-) if you want path(s) to be read from stdin."
17 ].join("\n\n "))
18 .option("-f <path>", "Specify conf filename other than \".editorconfig\"")
19 .option("-b <version>", "Specify version (used by devs to test compatibility)")
20 .option("-v, --version", "Display version information")
21 .parse(process.argv);
22
23// Throw away the native -V flag in lieu of the one we've manually specified
24// to adhere to testing requirements
25program.options.shift();
26
27var files = program.args;
28
29if (!files.length) {
30 program.help();
31}
32
33Promise.map(files, function(filePath) {
34 return editorconfig.parse(filePath, {config: program.F, version: program.B});
35}).each(function(parsed, i, length) {
36 if (length > 1) {
37 console.log("[%s]", files[i]);
38 }
39 Object.keys(parsed).forEach(function(key) {
40 console.log(key + "=" + parsed[key]);
41 });
42});