Commit f659526
Changed files (2)
src
test
src/core.ts
@@ -109,11 +109,13 @@ export const $ = new Proxy<Shell & Options>(
} as Shell & Options,
{
set(_, key, value) {
- Reflect.set(getStore(), key, value)
+ const target = key in Function.prototype ? _ : getStore()
+ Reflect.set(target, key, value)
return true
},
get(_, key) {
- return Reflect.get(getStore(), key)
+ const target = key in Function.prototype ? _ : getStore()
+ return Reflect.get(target, key)
},
}
)
test/core.test.js
@@ -425,4 +425,12 @@ test('malformed cmd error', async () => {
assert.throws(() => $`\033`, /malformed/i)
})
+test('$ is a regular function', async () => {
+ const _$ = $.bind(null)
+ let foo = await _$`echo foo`
+ assert.is(foo.stdout, 'foo\n')
+ assert.ok(typeof $.call === 'function')
+ assert.ok(typeof $.apply === 'function')
+})
+
test.run()