Skip to content
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

Allow passing args to run #8

Open
innovate-invent opened this issue Mar 19, 2020 · 5 comments
Open

Allow passing args to run #8

innovate-invent opened this issue Mar 19, 2020 · 5 comments

Comments

@innovate-invent
Copy link

Ideally, the run command should accept args in place of process.argv.

function run() {
...
if (arguments.length > 0) var args = arguments;
else var [, , ...args] = process.argv;
@EverlastingBugstopper
Copy link
Contributor

Hi @innovate-invent - do you have a specific use case for this? Happy to add support, just curious about the utility 😄

@innovate-invent
Copy link
Author

Applications installed via this utility can be run via the run() interface. Those applications expect command line arguments.
The run() function basically just acts as a convenient wrapper for child_process with some path resolution. It would be good to forward a bit more of the underlying interface.

@qm3ster
Copy link

qm3ster commented Apr 6, 2020

This would really help with a transient dependency here: wasm-tool/rollup-plugin-rust@9027e61
While it makes sense that install is a "binary" to run in npm scripts, in many cases a deep dependency binary is run programatically, which can be done more performantly and ergonomically without the .cmd -> .js -> stubs.

An alternative would be making _getBinaryPath public, so that people can do whatever they want with it, binary-install handling just the npm lifecycle. rustwasm/wasm-pack#827 <- possibly this change should be applied to the template?

qm3ster referenced this issue in wasm-tool/rollup-plugin-rust Apr 6, 2020
@iameli
Copy link

iameli commented Apr 8, 2020

I'd love this as well — use case is calling Wrangler programmatically from a CI script written in JavaScript.

@giraffekey
Copy link

Adding on top of this, returning from run would also be helpful. It's useful for projects that want the main CLI tool to be written in Node, but certain parts of it to be written in another language. For example if a CLI tool was written for a programming language:

const compiler = require("./compiler") // loads a compiler binary

function command_install(...) {...} // uses axios to install a package

function command_compile(...) {
    const args = preprocess(...) // do some preprocessing
    const stdout = compiler.run(args)
    postprocess(stdout)
}

If the language compiles to JavaScript, you may want to use an existing node package to minify the output before the file is saved to the system, but use a language better suited for compilation such as Rust to generate that initial output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants