Skip to content

Commit

Permalink
refactor: use promise finally silent hook
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 31, 2021
1 parent dc4608a commit 52c628a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ $.fs = {...$.fs, ...fs}
$.raw = async (...args) => {
const q = $.quote
$.quote = v => v
const p = $(...args)
await p
$.quote = q
return p
try {
return $(...args)
} finally {
$.quote = q
}
}

$.silent = async (...args) => {
const v = $.verbose
$.verbose = false
const p = $(...args)
await p
$.verbose = v
return p
return $(...args).finally(() => {$.verbose = v})
}

Object.assign(global, {
Expand Down

0 comments on commit 52c628a

Please sign in to comment.