Skip to content

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

Open

Description

@mattimatti

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

Activity

  1. Toddses commented on May 26, 2015

    @Toddses

    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.

  2. jollycic commented on Nov 27, 2015

    @jollycic

    +1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions