2788dc2f734212d0ae1a857f8b79807e244329dd7cdc1d5c31e86b84f975a869dd68f4ffc3e19b342c2f5d72dfc179ad451c04d9e3e653c37773b5fd92b204 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. var __importStar = (this && this.__importStar) || function (mod) {
  6. if (mod && mod.__esModule) return mod;
  7. var result = {};
  8. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  9. result["default"] = mod;
  10. return result;
  11. };
  12. Object.defineProperty(exports, "__esModule", { value: true });
  13. // tslint:disable:no-console
  14. var commander_1 = __importDefault(require("commander"));
  15. var editorconfig = __importStar(require("./"));
  16. var package_json_1 = __importDefault(require("../package.json"));
  17. function cli(args) {
  18. commander_1.default.version('EditorConfig Node.js Core Version ' + package_json_1.default.version);
  19. commander_1.default
  20. .usage([
  21. '[OPTIONS] FILEPATH1 [FILEPATH2 FILEPATH3 ...]',
  22. commander_1.default._version,
  23. 'FILEPATH can be a hyphen (-) if you want path(s) to be read from stdin.',
  24. ].join('\n\n '))
  25. .option('-f <path>', 'Specify conf filename other than \'.editorconfig\'')
  26. .option('-b <version>', 'Specify version (used by devs to test compatibility)')
  27. .option('-v, --version', 'Display version information')
  28. .parse(args);
  29. // Throw away the native -V flag in lieu of the one we've manually specified
  30. // to adhere to testing requirements
  31. commander_1.default.options.shift();
  32. var files = commander_1.default.args;
  33. if (!files.length) {
  34. commander_1.default.help();
  35. }
  36. files
  37. .map(function (filePath) { return editorconfig.parse(filePath, {
  38. config: commander_1.default.F,
  39. version: commander_1.default.B,
  40. }); })
  41. .forEach(function (parsing, i, _a) {
  42. var length = _a.length;
  43. parsing.then(function (parsed) {
  44. if (length > 1) {
  45. console.log("[" + files[i] + "]");
  46. }
  47. Object.keys(parsed).forEach(function (key) {
  48. console.log(key + "=" + parsed[key]);
  49. });
  50. });
  51. });
  52. }
  53. exports.default = cli;