File tree Expand file tree Collapse file tree 3 files changed +6
-19
lines changed
Expand file tree Collapse file tree 3 files changed +6
-19
lines changed Original file line number Diff line number Diff line change 2727 "micromatch" : " ^2.3.11" ,
2828 "node-notifier" : " ^5.1.2" ,
2929 "pify" : " ^3.0.0" ,
30+ "rimraf" : " ^2.5.4" ,
3031 "slash" : " ^1.0.0" ,
3132 "string-length" : " ^2.0.0" ,
3233 "strip-ansi" : " ^4.0.0" ,
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import {
1515 Console ,
1616 clearLine ,
1717 createDirectory ,
18- clearDirectory ,
1918 validateCLIOptions ,
2019} from 'jest-util' ;
2120import { readConfig } from 'jest-config' ;
@@ -33,6 +32,7 @@ import Runtime from 'jest-runtime';
3332import TestWatcher from '../test_watcher' ;
3433import watch from '../watch' ;
3534import yargs from 'yargs' ;
35+ import rimraf from 'rimraf' ;
3636
3737export async function run ( maybeArgv ?: Argv , project ?: Path ) {
3838 const argv : Argv = buildArgv ( maybeArgv , project ) ;
@@ -71,7 +71,10 @@ export const runCLI = async (
7171
7272 if ( argv . clearCache ) {
7373 configs . map ( config => {
74- clearDirectory ( config . cacheDirectory ) ;
74+ rimraf ( config . cacheDirectory , [ ] , ( ) => {
75+ process . stderr . write ( `Unable to clear ${ config . cacheDirectory } \n` ) ;
76+ process . exit ( 1 ) ;
77+ } ) ;
7578 process . stdout . write ( `Cleared ${ config . cacheDirectory } \n` ) ;
7679 } ) ;
7780
Original file line number Diff line number Diff line change 88 */
99
1010import mkdirp from 'mkdirp' ;
11- import fs from 'graceful-fs' ;
12- import path from 'path' ;
1311
1412import BufferedConsole from './buffered_console' ;
1513import clearLine from './clear_line' ;
@@ -32,26 +30,11 @@ const createDirectory = (path: string) => {
3230 }
3331} ;
3432
35- const clearDirectory = ( directoryPath : string ) => {
36- if ( fs . existsSync ( directoryPath ) ) {
37- fs . readdirSync ( directoryPath ) . map ( file => {
38- const filePath = path . join ( directoryPath , file ) ;
39- if ( fs . lstatSync ( filePath ) . isDirectory ( ) ) {
40- clearDirectory ( filePath ) ;
41- } else {
42- fs . unlinkSync ( filePath ) ;
43- }
44- } ) ;
45- fs . rmdirSync ( directoryPath ) ;
46- }
47- } ;
48-
4933module . exports = {
5034 BufferedConsole,
5135 Console,
5236 FakeTimers,
5337 NullConsole,
54- clearDirectory,
5538 clearLine,
5639 createDirectory,
5740 formatTestResults,
You can’t perform that action at this time.
0 commit comments