Skip to content

Commit 39725e2

Browse files
committed
Revert use logger.error, exit in watch when tsc exits
1 parent 1a859aa commit 39725e2

File tree

3 files changed

+8
-39
lines changed

3 files changed

+8
-39
lines changed

index.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const path = require("path");
22
const os = require("os");
33
const pty = require("node-pty");
4-
const stripAnsi = require("strip-ansi");
54

65
class TscError extends Error {
76
constructor(message) {
@@ -71,31 +70,17 @@ class TscWebpackPlugin {
7170

7271
ptyProcess.onData((data) => {
7372
if (isWatch) {
74-
const str = removeNewLinesAtEnd(data);
75-
const without = stripAnsi(str);
76-
77-
if (
78-
/Starting compilation in watch mode...$/.test(without) ||
79-
/Starting incremental compilation...$/.test(without) ||
80-
/Found 0 errors. Watching for file changes.$/.test(without)
81-
) {
82-
logger.info(str);
83-
} else {
84-
if (/Found [1-9][0-9]* errors?\b./.test(without)) {
85-
messages.push(str);
86-
logger.error(messages.join(""));
87-
88-
messages = [];
89-
} else {
90-
messages.push(data);
91-
}
92-
}
73+
logger.info(removeNewLinesAtEnd(data));
9374
} else {
9475
messages.push(data);
9576
}
9677
});
9778

98-
if (!isWatch) {
79+
if (isWatch) {
80+
ptyProcess.onExit((e) => {
81+
process.exit(e.exitCode);
82+
});
83+
} else {
9984
logger.info("Starting typechecking...");
10085

10186
compiler.hooks.afterEmit.tapPromise(PLUGIN_NAME, async (compilation) => {

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tsc-webpack-plugin",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "A TypeScript plugin for webpack.",
55
"author": "Damian Pieczynski [email protected]",
66
"main": "index.js",
@@ -20,12 +20,8 @@
2020
"bugs": {
2121
"url": "https://github.com/piecyk/tsc-webpack-plugin/issues"
2222
},
23-
"peerDependencies": {
24-
"webpack": "^4.0.0 || ^5.0.0"
25-
},
2623
"dependencies": {
27-
"node-pty": "^0.9.0",
28-
"strip-ansi": "^6.0.0"
24+
"node-pty": "^0.9.0"
2925
},
3026
"devDependencies": {
3127
"prettier": "^2.1.2"

yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# yarn lockfile v1
33

44

5-
ansi-regex@^5.0.0:
6-
version "5.0.0"
7-
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
8-
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
9-
105
nan@^2.14.0:
116
version "2.14.2"
127
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
@@ -23,10 +18,3 @@ prettier@^2.1.2:
2318
version "2.1.2"
2419
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
2520
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
26-
27-
strip-ansi@^6.0.0:
28-
version "6.0.0"
29-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
30-
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
31-
dependencies:
32-
ansi-regex "^5.0.0"

0 commit comments

Comments
 (0)