@@ -2,14 +2,14 @@ import * as path from 'path';
2
2
import * as process from 'process' ;
3
3
import * as childProcess from 'child_process' ;
4
4
import chalk , { Chalk } from 'chalk' ;
5
- import * as fs from 'fs' ;
6
5
import * as micromatch from 'micromatch' ;
7
6
import * as os from 'os' ;
8
7
import * as webpack from 'webpack' ;
9
8
import { CancellationToken } from './CancellationToken' ;
10
9
import { NormalizedMessage } from './NormalizedMessage' ;
11
10
import { createDefaultFormatter } from './formatter/defaultFormatter' ;
12
11
import { createCodeframeFormatter } from './formatter/codeframeFormatter' ;
12
+ import { FsHelper } from './FsHelper' ;
13
13
import { Message } from './Message' ;
14
14
15
15
import { AsyncSeriesHook , SyncHook } from 'tapable' ;
@@ -68,8 +68,14 @@ class ForkTsCheckerWebpackPlugin {
68
68
public static readonly DEFAULT_MEMORY_LIMIT = 2048 ;
69
69
public static readonly ONE_CPU = 1 ;
70
70
public static readonly ALL_CPUS = os . cpus && os . cpus ( ) ? os . cpus ( ) . length : 1 ;
71
- public static readonly ONE_CPU_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 1 ) ;
72
- public static readonly TWO_CPUS_FREE = Math . max ( 1 , ForkTsCheckerWebpackPlugin . ALL_CPUS - 2 ) ;
71
+ public static readonly ONE_CPU_FREE = Math . max (
72
+ 1 ,
73
+ ForkTsCheckerWebpackPlugin . ALL_CPUS - 1
74
+ ) ;
75
+ public static readonly TWO_CPUS_FREE = Math . max (
76
+ 1 ,
77
+ ForkTsCheckerWebpackPlugin . ALL_CPUS - 2
78
+ ) ;
73
79
74
80
public readonly options : Partial < Options > ;
75
81
private tsconfig : string ;
@@ -129,9 +135,8 @@ class ForkTsCheckerWebpackPlugin {
129
135
: options . tslint
130
136
: undefined ;
131
137
this . tslintAutoFix = options . tslintAutoFix || false ;
132
- this . watch = ( typeof options . watch === 'string' )
133
- ? [ options . watch ]
134
- : options . watch || [ ] ;
138
+ this . watch =
139
+ typeof options . watch === 'string' ? [ options . watch ] : options . watch || [ ] ;
135
140
this . ignoreDiagnostics = options . ignoreDiagnostics || [ ] ;
136
141
this . ignoreLints = options . ignoreLints || [ ] ;
137
142
this . reportFiles = options . reportFiles || [ ] ;
@@ -145,7 +150,7 @@ class ForkTsCheckerWebpackPlugin {
145
150
this . useColors = options . colors !== false ; // default true
146
151
this . colors = new chalk . constructor ( { enabled : this . useColors } ) ;
147
152
this . formatter =
148
- options . formatter && ( typeof options . formatter === 'function' )
153
+ options . formatter && typeof options . formatter === 'function'
149
154
? options . formatter
150
155
: ForkTsCheckerWebpackPlugin . createFormatter (
151
156
( options . formatter as 'default' | 'codeframe' ) || 'default' ,
@@ -201,8 +206,8 @@ class ForkTsCheckerWebpackPlugin {
201
206
this . watchPaths = this . watch . map ( this . computeContextPath . bind ( this ) ) ;
202
207
203
208
// validate config
204
- const tsconfigOk = fs . existsSync ( this . tsconfigPath ) ;
205
- const tslintOk = ! this . tslintPath || fs . existsSync ( this . tslintPath ) ;
209
+ const tsconfigOk = FsHelper . existsSync ( this . tsconfigPath ) ;
210
+ const tslintOk = ! this . tslintPath || FsHelper . existsSync ( this . tslintPath ) ;
206
211
207
212
// validate logger
208
213
if ( this . logger ) {
@@ -745,7 +750,10 @@ class ForkTsCheckerWebpackPlugin {
745
750
}
746
751
}
747
752
748
- private createEmitCallback ( compilation : webpack . compilation . Compilation , callback : ( ) => void ) {
753
+ private createEmitCallback (
754
+ compilation : webpack . compilation . Compilation ,
755
+ callback : ( ) => void
756
+ ) {
749
757
return function emitCallback ( this : ForkTsCheckerWebpackPlugin ) {
750
758
if ( ! this . elapsed ) {
751
759
throw new Error ( 'Execution order error' ) ;
0 commit comments