fork-ts-checker-webpack-plugin 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/CancellationToken.js +4 -2
- package/lib/FsHelper.d.ts +5 -0
- package/lib/FsHelper.js +20 -0
- package/lib/IncrementalChecker.js +2 -1
- package/lib/NormalizedMessage.js +1 -1
- package/lib/formatter/codeframeFormatter.js +2 -3
- package/lib/index.js +6 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## v0.5.2
|
|
2
|
+
|
|
3
|
+
* [Fix erroneous error on diagnostics at 0 line; remove deprecated fs.existsSync](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/190) (#190)
|
|
4
|
+
|
|
1
5
|
## v0.5.1
|
|
2
6
|
|
|
3
7
|
* [Make the checker compile with TypeScript 3.2](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/189)
|
package/lib/CancellationToken.js
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const ts = require("typescript");
|
|
8
|
+
const FsHelper_1 = require("./FsHelper");
|
|
8
9
|
class CancellationToken {
|
|
9
10
|
constructor(cancellationFileName, isCancelled) {
|
|
10
11
|
this.isCancelled = !!isCancelled;
|
|
@@ -33,7 +34,7 @@ class CancellationToken {
|
|
|
33
34
|
if (duration > 10) {
|
|
34
35
|
// check no more than once every 10ms
|
|
35
36
|
this.lastCancellationCheckTime = time;
|
|
36
|
-
this.isCancelled =
|
|
37
|
+
this.isCancelled = FsHelper_1.FsHelper.existsSync(this.getCancellationFilePath());
|
|
37
38
|
}
|
|
38
39
|
return this.isCancelled;
|
|
39
40
|
}
|
|
@@ -47,7 +48,8 @@ class CancellationToken {
|
|
|
47
48
|
this.isCancelled = true;
|
|
48
49
|
}
|
|
49
50
|
cleanupCancellation() {
|
|
50
|
-
if (this.isCancelled &&
|
|
51
|
+
if (this.isCancelled &&
|
|
52
|
+
FsHelper_1.FsHelper.existsSync(this.getCancellationFilePath())) {
|
|
51
53
|
fs.unlinkSync(this.getCancellationFilePath());
|
|
52
54
|
this.isCancelled = false;
|
|
53
55
|
}
|
package/lib/FsHelper.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
class FsHelper {
|
|
5
|
+
static existsSync(filePath) {
|
|
6
|
+
try {
|
|
7
|
+
fs.statSync(filePath);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
if (err.code === 'ENOENT') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.FsHelper = FsHelper;
|
|
@@ -9,6 +9,7 @@ const WorkSet_1 = require("./WorkSet");
|
|
|
9
9
|
const NormalizedMessage_1 = require("./NormalizedMessage");
|
|
10
10
|
const minimatch = require("minimatch");
|
|
11
11
|
const VueProgram_1 = require("./VueProgram");
|
|
12
|
+
const FsHelper_1 = require("./FsHelper");
|
|
12
13
|
class IncrementalChecker {
|
|
13
14
|
constructor(programConfigFile, compilerOptions, linterConfigFile, linterAutoFix, watchPaths, workNumber = 0, workDivision = 1, checkSyntacticErrors = false, vue = false) {
|
|
14
15
|
this.programConfigFile = programConfigFile;
|
|
@@ -167,7 +168,7 @@ class IncrementalChecker {
|
|
|
167
168
|
linter.lint(fileName, undefined, this.linterConfig);
|
|
168
169
|
}
|
|
169
170
|
catch (e) {
|
|
170
|
-
if (
|
|
171
|
+
if (FsHelper_1.FsHelper.existsSync(fileName) &&
|
|
171
172
|
// check the error type due to file system lag
|
|
172
173
|
!(e instanceof Error) &&
|
|
173
174
|
!(e.constructor.name === 'FatalError') &&
|
package/lib/NormalizedMessage.js
CHANGED
|
@@ -18,7 +18,7 @@ class NormalizedMessage {
|
|
|
18
18
|
let character;
|
|
19
19
|
if (diagnostic.file) {
|
|
20
20
|
file = diagnostic.file.fileName;
|
|
21
|
-
if (
|
|
21
|
+
if (diagnostic.start === undefined) {
|
|
22
22
|
throw new Error('Expected diagnostics to have start');
|
|
23
23
|
}
|
|
24
24
|
const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
@@ -4,6 +4,7 @@ const os = require("os");
|
|
|
4
4
|
const codeFrame = require("babel-code-frame");
|
|
5
5
|
const chalk_1 = require("chalk");
|
|
6
6
|
const fs = require("fs");
|
|
7
|
+
const FsHelper_1 = require("../FsHelper");
|
|
7
8
|
/**
|
|
8
9
|
* Create new code frame formatter.
|
|
9
10
|
*
|
|
@@ -18,9 +19,7 @@ function createCodeframeFormatter(options) {
|
|
|
18
19
|
: colors.bold.red;
|
|
19
20
|
const positionColor = colors.dim;
|
|
20
21
|
const file = message.file;
|
|
21
|
-
const source = file &&
|
|
22
|
-
fs.existsSync(file) &&
|
|
23
|
-
fs.readFileSync(file, 'utf-8');
|
|
22
|
+
const source = file && FsHelper_1.FsHelper.existsSync(file) && fs.readFileSync(file, 'utf-8');
|
|
24
23
|
let frame = '';
|
|
25
24
|
if (source) {
|
|
26
25
|
frame = codeFrame(source, message.line, // Assertion: `codeFrame` allows passing undefined, typings are incorrect
|
package/lib/index.js
CHANGED
|
@@ -3,13 +3,13 @@ const path = require("path");
|
|
|
3
3
|
const process = require("process");
|
|
4
4
|
const childProcess = require("child_process");
|
|
5
5
|
const chalk_1 = require("chalk");
|
|
6
|
-
const fs = require("fs");
|
|
7
6
|
const micromatch = require("micromatch");
|
|
8
7
|
const os = require("os");
|
|
9
8
|
const CancellationToken_1 = require("./CancellationToken");
|
|
10
9
|
const NormalizedMessage_1 = require("./NormalizedMessage");
|
|
11
10
|
const defaultFormatter_1 = require("./formatter/defaultFormatter");
|
|
12
11
|
const codeframeFormatter_1 = require("./formatter/codeframeFormatter");
|
|
12
|
+
const FsHelper_1 = require("./FsHelper");
|
|
13
13
|
const tapable_1 = require("tapable");
|
|
14
14
|
const checkerPluginName = 'fork-ts-checker-webpack-plugin';
|
|
15
15
|
const customHooks = {
|
|
@@ -45,9 +45,8 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
45
45
|
: options.tslint
|
|
46
46
|
: undefined;
|
|
47
47
|
this.tslintAutoFix = options.tslintAutoFix || false;
|
|
48
|
-
this.watch =
|
|
49
|
-
? [options.watch]
|
|
50
|
-
: options.watch || [];
|
|
48
|
+
this.watch =
|
|
49
|
+
typeof options.watch === 'string' ? [options.watch] : options.watch || [];
|
|
51
50
|
this.ignoreDiagnostics = options.ignoreDiagnostics || [];
|
|
52
51
|
this.ignoreLints = options.ignoreLints || [];
|
|
53
52
|
this.reportFiles = options.reportFiles || [];
|
|
@@ -61,7 +60,7 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
61
60
|
this.useColors = options.colors !== false; // default true
|
|
62
61
|
this.colors = new chalk_1.default.constructor({ enabled: this.useColors });
|
|
63
62
|
this.formatter =
|
|
64
|
-
options.formatter &&
|
|
63
|
+
options.formatter && typeof options.formatter === 'function'
|
|
65
64
|
? options.formatter
|
|
66
65
|
: ForkTsCheckerWebpackPlugin.createFormatter(options.formatter || 'default', options.formatterOptions || {});
|
|
67
66
|
this.tsconfigPath = undefined;
|
|
@@ -102,8 +101,8 @@ class ForkTsCheckerWebpackPlugin {
|
|
|
102
101
|
: undefined;
|
|
103
102
|
this.watchPaths = this.watch.map(this.computeContextPath.bind(this));
|
|
104
103
|
// validate config
|
|
105
|
-
const tsconfigOk =
|
|
106
|
-
const tslintOk = !this.tslintPath ||
|
|
104
|
+
const tsconfigOk = FsHelper_1.FsHelper.existsSync(this.tsconfigPath);
|
|
105
|
+
const tslintOk = !this.tslintPath || FsHelper_1.FsHelper.existsSync(this.tslintPath);
|
|
107
106
|
// validate logger
|
|
108
107
|
if (this.logger) {
|
|
109
108
|
if (!this.logger.error || !this.logger.warn || !this.logger.info) {
|