Skip to content

Take -version from package.json #48

@youurayy

Description

@youurayy

E.g.

program.version(JSON.parse(require('fs').readFileSync(
     require.main.filename.match(/^(.+)\/.+$/)[1] + '/../package.json')).version)

But a test is needed for the existence of package.json, I think the 2 most used locations are and /.

So 1, check for main_module_dir/package.json and 2, check for main_module_dir/../package.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions