75lb / command-line-args

A mature, feature-complete library to parse command-line options.
MIT License
679 stars 107 forks source link

Parse correctly when Node runs with --eval or -e #101

Closed zawataki closed 5 years ago

zawataki commented 5 years ago

Parse correctly when Node.js runs with --eval or -e option

75lb commented 5 years ago

Hi, thanks for the contribution. Could you send me a reproduction case i could use to test this works please? For example, send a test script and a command I can run to prove it works.

zawataki commented 5 years ago

@75lb I got it, will send it.

zawataki commented 5 years ago

@75lb I tested by the following steps.

  1. Prepare the following contents as a file called test.sh
    
    #!/bin/bash

npm i -g command-line-args node -e " const commandLineArgs = require('command-line-args') const optionDefinitions = [ { name: 'value', type: String, } ]; const options = commandLineArgs(optionDefinitions);

console.log('options: ', options); " --value foo


2. Run the following command
```bash
docker run -it --rm node:10.15.3-slim bash -c "$(cat test.sh)"
  1. The following messages will be outputted when without this PR
    + command-line-args@5.1.0
    added 5 packages from 4 contributors in 0.545s
    node: bad option: --value
zawataki commented 5 years ago

Thank you for merging.

75lb commented 5 years ago

Fixed and released in v5.1.1.

Let me know if you find any more issues. 👍 🇯🇵

zawataki commented 5 years ago

Great, thanks a lot for quick release! The latest version works fine. 😄