Catch result from `exec` command to allow formatting.
See original GitHub issueIs there a way to catch the ouput of an exec
command?
Is there a way to get the output from an exec
command without writing it to the terminal right away? I would like to modify the output of some commands that read files by appending the keepWords
option through using the echo
command to break lines correctly (this would resolve the issue of pages being indexed by bots incorrectly due to added div elements on weird places in the source).
For example, this.echo('a long text here', {keepWords: true})
will do exactly what I want.
But in my case I store text files which are readable with a cat
command.
For example: this.exec('cat filename.info', true);
, or this.echo('[[cat filename.info]]', {keepWords: true});
, but in both cases words are not kept together.
I’ve tried several things to apply echo
options on an exec
command.
- Manipulate the promise of
this.exec('command with arguments')
- Execute content inside echo
this.echo('[[command with arguments]]', {keepWords: true});
- Trying some things inside the
onBeforeCommand
andonAfterCommand
.
Please let me know if I need to supply more information. Finally, thank you for writing and maintaining this project.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (8 by maintainers)
Top GitHub Comments
You can add options to command like:
and in cat command you can parse the command, you will need to disable arity if you use object as argument.
if you use function to get args array like this:
renderHandler
was added in version 2.9.0. With this new API you just need to return object from server{echo: 'string', options: {keepWords: true}}
and in render handler you check if value is plainObject and if it have echo property if so you echo the string and use options: