UNPKG

2.4 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11const child_process_1 = require("child_process");
12const path_1 = require("path");
13const process_1 = require("process");
14const kProjectRoot = process_1.cwd();
15const kTSLintArguments = [
16 '--config', path_1.resolve(__dirname, '..', 'tslint.json'),
17 '--exclude', path_1.join(kProjectRoot, '**', 'node_modules', '**', '*'),
18 '--exclude', path_1.join(kProjectRoot, '**', 'dist', '**', '*'),
19 '--project', path_1.join(kProjectRoot, 'tsconfig.json'),
20 path_1.join(kProjectRoot, '**', '*.{ts,tsx}')
21];
22const kSpawnOptions = {
23 stdio: 'inherit',
24 shell: /^win/.test(process_1.platform)
25};
26const kPaths = [
27 path_1.resolve(__dirname, '..', 'node_modules', '.bin', 'tslint'),
28 'tslint'
29];
30function runTSLint(path) {
31 return __awaiter(this, void 0, void 0, function* () {
32 return new Promise((resolve, reject) => {
33 let didFailToSpawn = false;
34 return child_process_1.spawn(path, kTSLintArguments, kSpawnOptions)
35 .on('error', err => {
36 didFailToSpawn = true;
37 return reject(err);
38 })
39 .on('exit', code => {
40 if (!didFailToSpawn) {
41 return resolve(code || 0);
42 }
43 });
44 });
45 });
46}
47(function findAndRunTSLint(paths) {
48 return __awaiter(this, void 0, void 0, function* () {
49 for (const path of paths) {
50 try {
51 const code = yield runTSLint(path);
52 return process_1.exit(code);
53 }
54 catch (err) {
55 continue;
56 }
57 }
58 return process_1.exit(-1);
59 });
60})(kPaths).catch(() => process_1.exit(-1));
61//# sourceMappingURL=index.js.map
\No newline at end of file