File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,12 @@ import {
41
41
exitCodeInfo ,
42
42
formatCmd ,
43
43
getCallerLocation ,
44
+ isString ,
44
45
noop ,
45
46
parseDuration ,
47
+ preferNmBin ,
46
48
quote ,
47
49
quotePowerShell ,
48
- preferNmBin ,
49
50
} from './util.js'
50
51
51
52
export interface Shell {
@@ -445,7 +446,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
445
446
}
446
447
447
448
pipe ( dest : Writable | ProcessPromise ) : ProcessPromise {
448
- if ( typeof dest === 'string' )
449
+ if ( isString ( dest ) )
449
450
throw new Error ( 'The pipe() method does not take strings. Forgot $?' )
450
451
if ( this . _resolved ) {
451
452
if ( dest instanceof ProcessPromise ) dest . stdin . end ( ) // In case of piped stdin, we may want to close stdin of dest as well.
Original file line number Diff line number Diff line change @@ -740,17 +740,22 @@ describe('core', () => {
740
740
await promise
741
741
} )
742
742
743
- test ( 'restores previous cwd' , async ( ) => {
743
+ test ( 'keeps the cwd ref for internal $ calls ' , async ( ) => {
744
744
let resolve , reject
745
745
let promise = new Promise ( ( ...args ) => ( [ resolve , reject ] = args ) )
746
-
746
+ let cwd = process . cwd ( )
747
747
let pwd = await $ `pwd`
748
748
749
749
within ( async ( ) => {
750
750
cd ( '/tmp' )
751
+ assert . ok ( process . cwd ( ) . endsWith ( '/tmp' ) )
752
+ assert . ok ( ( await $ `pwd` ) . stdout . trim ( ) . endsWith ( '/tmp' ) )
753
+
751
754
setTimeout ( async ( ) => {
755
+ process . chdir ( '/' )
752
756
assert . ok ( ( await $ `pwd` ) . stdout . trim ( ) . endsWith ( '/tmp' ) )
753
757
resolve ( )
758
+ process . chdir ( cwd )
754
759
} , 1000 )
755
760
} )
756
761
You can’t perform that action at this time.
0 commit comments