Skip to content

Commit aca34f1

Browse files
committed
feat: disable $.cwdHook by default
BREAKING CHANGE: affects legacy cd() flow
1 parent d969231 commit aca34f1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const $: Shell & Options = new Proxy<Shell & Options>(
191191
},
192192
}
193193
)
194-
$.cwdHook = true
194+
$.cwdHook = false
195195
try {
196196
setupBash()
197197
} catch (err) {}

test/core.test.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,11 @@ describe('core', () => {
233233
})
234234

235235
test('$.cwdHook is configurable', () => {
236-
$.cwdHook = false
237-
assert.equal($.cwdHook, false)
238236
$.cwdHook = true
239237
assert.equal($.cwdHook, true)
238+
239+
$.cwdHook = false
240+
assert.equal($.cwdHook, false)
240241
})
241242

242243
test('cd() works with relative paths', async () => {
@@ -270,7 +271,8 @@ describe('core', () => {
270271
}
271272
})
272273

273-
test('cd() does not affect parallel contexts', async () => {
274+
test('cd() does not affect parallel contexts ($.cwdHook enabled)', async () => {
275+
$.cwdHook = true
274276
const cwd = process.cwd()
275277
try {
276278
fs.mkdirpSync('/tmp/zx-cd-parallel/one/two')
@@ -304,6 +306,7 @@ describe('core', () => {
304306
} finally {
305307
fs.rmSync('/tmp/zx-cd-parallel', { recursive: true })
306308
cd(cwd)
309+
$.cwdHook = false
307310
}
308311
})
309312

0 commit comments

Comments
 (0)