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

cli.setApp('package.json') installed globally #54

Open
mattimatti opened this issue Oct 2, 2014 · 2 comments
Open

cli.setApp('package.json') installed globally #54

mattimatti opened this issue Oct 2, 2014 · 2 comments

Comments

@mattimatti
Copy link

Hello,
In order to have properly read the package.json, when the cli app is installed globally I have to reference the package.json this way. better solutions appreciated.

var path = require('path');
var cli = require('cli');

var theFolder = path.dirname(require.main.filename);
var theFile = path.resolve(theFolder + '/../package.json');

cli.setApp(theFile);

Ciao
:m

@Toddses
Copy link

Toddses commented May 26, 2015

One way is

cli.setApp(__dirname+'/../package.json');

That said, that's only better in that it’s a one-liner.

This actually is also true if cli is installed as a local package. The documentation seems to imply that the default behavior of appname --version would return the appname's version. But in fact you get cli's version, not your appname. You end up explicitly defining the app's package as above.

@chriso Is this intended behavior? If so, an update to the docs to make this a little clearer would be useful.

@jollycic
Copy link

+1

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

3 participants