Coder Social home page Coder Social logo

Comments (7)

zkat avatar zkat commented on July 16, 2024 1

@stuartpb Everything in this issue has (I believe) been implemented as of [email protected]. Thanks for all the ideas! Please do keep them coming. I'll close this issue in particular, though. (and if what you described here doesn't work, it might be a bug, and worth fixing).

from npx.

zkat avatar zkat commented on July 16, 2024

Thanks for the suggestion! This was almost exactly what I was doing already buuuut it works now:

screen shot 2017-05-29 at 17 57 41

This'll be included when I actually release npx. To be clear: I split out everything after <command> and it is interpreted entirely by <command> at that point. Only things left of the command are parsed by npx.

from npx.

stuartpb avatar stuartpb commented on July 16, 2024

👍

Is -- to explicitly signify that the next argument is <command> implemented?

from npx.

zkat avatar zkat commented on July 16, 2024

@stuartpb oh. No, not that. I don't think I would do that. The first non-option argument is always interpreted as a command, and it will be used exactly as-is if you provide a -p option. npx itself accepts no variadic argument, so the parser is able to disambiguate this easily enough.

Therefore, npx -p $mypackage@$myversion $@ will be interpreted the way you're describing, unless I misunderstood something.

from npx.

stuartpb avatar stuartpb commented on July 16, 2024

The first non-option argument is always interpreted as a command, and it will be used exactly as-is if you provide a -p option. npx itself accepts no variadic argument, so the parser is able to disambiguate this easily enough.

Well, no, because you can have a command with the same name as an option. It's perfectly valid to have a bin script called -c - it might not be advisable (due to the potential confusion in scenarios just like this), but it can make sense in certain contexts (for instance, for a package that, itself, uses scripts for arguments to the script itself - imagine a project that ran its crispify script when called as foobar crispify, then wanted to add foobar -c as a variant alias for drop-in intercompatibility with a similar tool). Without -- to signal "the next argument is the beginning of the command", there's no way to distinguish this unambiguously.

from npx.

stuartpb avatar stuartpb commented on July 16, 2024

Illustrated:

npx -p foo -c 'require("alert")(1)'
# executes 'require("alert")(1)' in an npm run-script environment

npx -p foo -- -c 'require("alert")(1)'
# runs the script '-c' with 'require("alert")(1)' as its first argument

from npx.

stuartpb avatar stuartpb commented on July 16, 2024

💯

from npx.

Related Issues (20)

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.