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

NPM js-beautify: different treatment of "-" in command line #390

Closed
einars opened this issue Jan 22, 2014 · 8 comments
Closed

NPM js-beautify: different treatment of "-" in command line #390

einars opened this issue Jan 22, 2014 · 8 comments

Comments

@einars
Copy link
Contributor

einars commented Jan 22, 2014

Is it possible that "-" as a parameter is being treated differently in the situation if the script is run from the git checkout, or from npm install?

js-beautify@1.4.2 installed via npm:
% js-beautify -
Unable to open path "/home/e/-"

git checkout, v1.4.2:
% ./js/bin/js-beautify.js -
[waiting for stdin]

@evocateur
Copy link
Contributor

Yikes. I don't use the - arg very much, maybe there's a dependency version issue? I'll try to look into it later today.

@einars
Copy link
Contributor Author

einars commented Jan 22, 2014

I don't use it much either, but there was a confused user in comments for #27 who couldn't find how to use the reading from stdin, and I was surprised that my quick "js-beautify -" verification in the terminal failed.

@kevinoid
Copy link

kevinoid commented Oct 1, 2014

@einars, is it possible that you are using an older version of nopt in your git checkout? It looks like the handling of '-' was changed in npm/nopt@649d969 between nopt v2.1.1 and v2.1.2 where v2.1.1 would return

{
  "argv": {
    "remain": [],
    "cooked": [],
    "original": [
      "-"
    ]
  }
}

while v2.1.2 returns

{
  "argv": {
    "remain": [
      "-"
    ],
    "cooked": [
      "-"
    ],
    "original": [
      "-"
    ]
  }
}

which causes execution to enter the loop at js/lib/cli.js:389.

+1 for supporting js-beautify - again.

@bitwiseman
Copy link
Member

We're now up to nopt v3.0.1. 😄
But yes, it is possible to have the npm install'd version use the global node_modules, and the local git version use the local modules, and have them differ.

@cdosborn
Copy link

From npm, the command does not seem to handle stdin.

$ js-beautify - <<< "var x = 3"
Unable to open path "my/home/path/blah-"
Run `js-beautify -h` for help.

$ npm -v js-beautify
1.4.3

$ npm version
{ http_parser: '1.0',
  node: '0.10.26',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.25',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1e',
  npm: '1.4.3' }

@bitwiseman bitwiseman added this to the v1.6.0 milestone Mar 25, 2015
@bitwiseman
Copy link
Member

@cdosborn - Thanks!
Here's a work around for the moment:

$ js-beautify -f - <<< "var x = 3"
var x = 3

There's a pull request already in for improving this area, so maybe this will get into the next release.

@cdosborn
Copy link

Thanks, looking forward.

@bitwiseman
Copy link
Member

This looks to be fixed for the next version.

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

No branches or pull requests

5 participants