File tree 3 files changed +10
-6
lines changed
3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ import {silentNg} from '../../utils/process';
2
2
3
3
4
4
export default function ( ) {
5
- const projectDir = process . cwd ( ) ;
6
5
return Promise . resolve ( )
7
6
. then ( ( ) => silentNg ( 'help' ) )
8
7
. then ( ( ) => process . chdir ( '/' ) )
9
- . then ( ( ) => silentNg ( 'help' ) )
10
- . then ( ( ) => process . chdir ( projectDir ) ) ;
8
+ . then ( ( ) => silentNg ( 'help' ) ) ;
11
9
}
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ import {expectFileSizeToBeUnder} from '../../../utils/fs';
6
6
7
7
8
8
export default function ( argv : any , skipCleaning : ( ) => void ) {
9
- const currentDir = process . cwd ( ) ;
10
-
11
9
if ( process . platform . startsWith ( 'win' ) ) {
12
10
// Disable the test on Windows.
13
11
return Promise . resolve ( ) ;
@@ -24,6 +22,5 @@ export default function(argv: any, skipCleaning: () => void) {
24
22
. then ( ( ) => exec ( 'node_modules/.bin/webpack' , '-p' ) )
25
23
. then ( ( ) => expectFileSizeToBeUnder ( 'dist/app.main.js' , 400000 ) )
26
24
. then ( ( ) => expectFileSizeToBeUnder ( 'dist/0.app.main.js' , 40000 ) )
27
- . then ( ( ) => process . chdir ( currentDir ) )
28
25
. then ( ( ) => skipCleaning ( ) ) ;
29
26
}
Original file line number Diff line number Diff line change @@ -92,10 +92,19 @@ testsToRun.reduce((previous, relativeName) => {
92
92
} ;
93
93
94
94
let clean = true ;
95
+ let previousDir = null ;
95
96
return Promise . resolve ( )
96
97
. then ( ( ) => printHeader ( currentFileName ) )
98
+ . then ( ( ) => previousDir = process . cwd ( ) )
97
99
. then ( ( ) => fn ( argv , ( ) => clean = false ) )
98
100
. then ( ( ) => console . log ( ' ----' ) )
101
+ . then ( ( ) => {
102
+ // If we're not in a setup, change the directory back to where it was before the test.
103
+ // This allows tests to chdir without worrying about keeping the original directory.
104
+ if ( allSetups . indexOf ( relativeName ) == - 1 && previousDir ) {
105
+ process . chdir ( previousDir ) ;
106
+ }
107
+ } )
99
108
. then ( ( ) => {
100
109
// Only clean after a real test, not a setup step. Also skip cleaning if the test
101
110
// requested an exception.
You can’t perform that action at this time.
0 commit comments