@@ -2,14 +2,14 @@ import * as path from 'path';
22import * as process from 'process' ;
33import * as childProcess from 'child_process' ;
44import chalk , { Chalk } from 'chalk' ;
5- import * as fs from 'fs' ;
65import * as micromatch from 'micromatch' ;
76import * as os from 'os' ;
87import * as webpack from 'webpack' ;
98import { CancellationToken } from './CancellationToken' ;
109import { NormalizedMessage } from './NormalizedMessage' ;
1110import { createDefaultFormatter } from './formatter/defaultFormatter' ;
1211import { createCodeframeFormatter } from './formatter/codeframeFormatter' ;
12+ import { FsHelper } from './FsHelper' ;
1313import { Message } from './Message' ;
1414
1515import { AsyncSeriesHook , SyncHook } from 'tapable' ;
@@ -68,8 +68,14 @@ class ForkTsCheckerWebpackPlugin {
6868 public static readonly DEFAULT_MEMORY_LIMIT = 2048 ;
6969 public static readonly ONE_CPU = 1 ;
7070 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+ ) ;
7379
7480 public readonly options : Partial < Options > ;
7581 private tsconfig : string ;
@@ -129,9 +135,8 @@ class ForkTsCheckerWebpackPlugin {
129135 : options . tslint
130136 : undefined ;
131137 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 || [ ] ;
135140 this . ignoreDiagnostics = options . ignoreDiagnostics || [ ] ;
136141 this . ignoreLints = options . ignoreLints || [ ] ;
137142 this . reportFiles = options . reportFiles || [ ] ;
@@ -145,7 +150,7 @@ class ForkTsCheckerWebpackPlugin {
145150 this . useColors = options . colors !== false ; // default true
146151 this . colors = new chalk . constructor ( { enabled : this . useColors } ) ;
147152 this . formatter =
148- options . formatter && ( typeof options . formatter === 'function' )
153+ options . formatter && typeof options . formatter === 'function'
149154 ? options . formatter
150155 : ForkTsCheckerWebpackPlugin . createFormatter (
151156 ( options . formatter as 'default' | 'codeframe' ) || 'default' ,
@@ -201,8 +206,8 @@ class ForkTsCheckerWebpackPlugin {
201206 this . watchPaths = this . watch . map ( this . computeContextPath . bind ( this ) ) ;
202207
203208 // 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 ) ;
206211
207212 // validate logger
208213 if ( this . logger ) {
@@ -745,7 +750,10 @@ class ForkTsCheckerWebpackPlugin {
745750 }
746751 }
747752
748- private createEmitCallback ( compilation : webpack . compilation . Compilation , callback : ( ) => void ) {
753+ private createEmitCallback (
754+ compilation : webpack . compilation . Compilation ,
755+ callback : ( ) => void
756+ ) {
749757 return function emitCallback ( this : ForkTsCheckerWebpackPlugin ) {
750758 if ( ! this . elapsed ) {
751759 throw new Error ( 'Execution order error' ) ;
0 commit comments