-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document Halt #961
Labels
Comments
You can do it right now: const p = $({halt: true})`cdm --foo=${foo}`
console.log(f.cmd)
const o = await p.run() You can inject verification layer in various ways:
const _$ = (pieces: TemplateStringsArray | Partial<Options>, ...args: any) => {
if (isTemplateString(pieces, args)) {
const p = $({halt: true}).apply(...)
console.log(f.cmd)
const o = await p.run()
}
return ...
}
const _run = ProcessPromise.prototype.run
ProcessPromise.prototype.run = function () {
// ... custom check
return _run.call(this)
}
const _log = $.log
const _$ = $({log: (entry) => {
if (entry.kind === 'cmd') {
// ... check
}
return _log(entry)
}}) |
Yeah, that looks like what I want! I'd seen halt in intellisense but it isn't documented, so I didn't know what it did. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIT: Halt should get documented so people can know how it exists.
Old description below:
Hello! I'm trying to convert some existing code that uses
child_process
to zx. It's working fine, but I want to print out the commands that are run. I know I can enable verbose mode and override the logger, but that isn't as flexible as the logging I need to do. I see zx 8 useszurk
under the hood, which has abuildCmd
function. While that could work, it's not a template tag, so I'd need to manually verify it's actually what zx is running. I'd love an API to create commands without running them (as I think about it, it'd also be useful if xz exposed an exec function to run a command from the proposed builder tag).The text was updated successfully, but these errors were encountered: