Code Monkey home page Code Monkey logo

deno-exec's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deno-exec's Issues

Tee and StdOut modes seem to have no effect

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

Lock version of uuid

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

publish a new version for stderrResult

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.

Typo in README.md

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

Print errors and throw exception on end of process when continueOnError is false

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.

Never finishes when there is a lot of STDOUT

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;

  • Google for something random
  • Copy-paste the entire browser window into a text file like a brute. Repeat until you have 10000 lines
  • Save as long.txt
  • Create a file with the following Deno code
    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');
    })();
  • Run 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

  • Either "Done" or an error message is console.logged

Observed

  • Only "Started" is logged, code execution never gets past await exec nor does it throw an error

stderr?

Is stderr ignored? I have some commands failing, but I don't see any output.

cwd missing?

Setting the cwd is the only thing I find I often need to set

Support piping

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?

Missing random uuid

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.