gpasq / deno-exec Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
When running with Deno 1.3.0, the Tee and StdOut modes seem to have no effect.
import { exec, OutputMode } from "https://deno.land/x/[email protected]/mod.ts";
const p1 = await exec('bash -c echo one && sleep 1 && echo two', { output: OutputMode.Tee }); // displays nothing
console.log(await p1.output); // displays nothing
const p2 = await exec('bash -c echo one && sleep 1 && echo two', { output: OutputMode.StdOut }); // displays nothing
console.log(await p2.output); // displays nothing
Commands starting with bash -c ...
seem to have an impact. Running something simple, like exec('echo hello', { output: OutputMode.StdOut });
works as expected. So does this command bash --help
, so it's probably not related to calling bash itself
Either lock the version of the uuid package or update it to reflect the latest version of the package.
I am encountering an error on line 51
TypeError: v4.generate is not a function
The current 0.0.5 version can not return stderrResult.
The version released through deno x will be accelerated by CDN, so please release a new version.
I think this was supposed to read "in a case like this"
When you think of piping in a case list this, you often think of something like
It would be nice if exec
would provide a quick way to get something similar to that without that extra function:
async function run(cwd: string, ...cmd: string[]): Promise<Deno.ProcessStatus> {
const p = Deno.run({
cmd,
cwd,
stdout: "piped",
stderr: "piped"
})
for await (const line of io.readLines(p.stdout)) {
console.info(`[ ${cmd[0]} ] ${line}`)
}
for await (const line of io.readLines(p.stderr)) {
console.error(`[ ${cmd[0]} ] ${line}`)
}
const status: Deno.ProcessStatus = await p.status()
if(!status.success) {
throw new Error(`[ ${cmd[0]} ] failed with exit code ${status.code}`)
}
return status
}
I'm running something like this:
await run.exec(`ssh ${sshAlias} [ -w /vars ]`, {
output: run.OutputMode.StdOut,
verbose: true,
continueOnError: false
})
which should fail (/vars
does not exist on my server, it's just a test). Using the run function above I would get an error message and an exception is thrown, the same is not true for exec
. I get just verbose log, no output and the script continues despite the error.
When the command ran with exec('the command')
has a large response await process.status()
never resolves, blocking exec
from resolving also.
I noticed this bug when running some git
command that returned a long file list. I've managed to reproduce the problem with an arbitrary large text file and running exec('ls long.txt')
To reproduce;
long.txt
import { exec } from 'https://deno.land/x/[email protected]/mod.ts';
(async () => {
console.log('Started');
try {
await exec('cat long.txt');
} catch (error) {
console.log(error.message);
}
console.log('Done');
})();
deno run --allow-run isolated-test.ts
(Alternatively, you can just execute the Deno code and modify it to run curl https://pastebin.com/raw/WYvij310
, which is a sufficiently large file found somewhere on the internet)
Expected
Observed
await exec
nor does it throw an errorIs stderr
ignored? I have some commands failing, but I don't see any output.
Setting the cwd
is the only thing I find I often need to set
I know that we can do bash -c '...
for piping scenarios, but this is not platform independent. It would be nice if natural piping was supported in this lib as a feature.
If you want to implement your own piping within the app, you can (currently) capture the output of one exec call and pass it to the next.
How do I use stdin with exec?
Currently when I tried to run commands with heredoc it errored out.
I want to know if something like can be executed using exec
cat << EOF
The current working directory is: $PWD
You are logged in as: $(whoami)
EOF
We are getting this error, please advise.
error: TS2339 [ERROR]: Property 'randomUUID' does not exist on type 'Crypto'.
--
| return crypto.randomUUID();
at https://deno.land/[email protected]/uuid/v4.ts:30:17
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.