Skip to content

Issue with entry script version #424

Open
@gunnx

Description

@gunnx

Following the guide in: https://github.com/commitizen/cz-cli#1-create-your-own-entry-point-script

It works when using npm link but when I install from npm it throws the following error.
It looks like its trying to read a package.json that is nested under my custom-commit package but commitizen package is directly under node_modules not my package.

{ Error: ENOENT: no such file or directory, open '/Users/test123/repos/test/npm/node_modules/custom-commit/node_modules/commitizen/package.json'
    at Object.fs.openSync (fs.js:558:18)
    at Object.fs.readFileSync (fs.js:468:33)
    at getParsedJsonFromFile (/Users/test123/repos/test/npm/node_modules/commitizen/dist/common/util.js:43:44)
    at getParsedPackageJsonFromPath (/Users/test123/repos/test/npm/node_modules/commitizen/dist/common/util.js:54:10)
    at /Users/test123/repos/test/npm/node_modules/commitizen/dist/cli/strategies/git-cz.js:92:65
    at /Users/test123/repos/test/npm/node_modules/commitizen/dist/commitizen/staging.js:25:5
    at ChildProcess.exithandler (child_process.js:202:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/test123/repos/test/npm/node_modules/custom-commit/node_modules/commitizen/package.json' }
/Users/test123/repos/test/npm/node_modules/commitizen/dist/cli/strategies/git-cz.js:93
    console.log('cz-cli@' + cliPackageJson.version + ', ' + adapterPackageJson.name + '@' + adapterPackageJson.version + '\n');
                                          ^

TypeError: Cannot read property 'version' of undefined
    at /Users/test123/repos/test/npm/node_modules/commitizen/dist/cli/strategies/git-cz.js:93:43
    at /Users/test123/repos/test/npm/node_modules/commitizen/dist/commitizen/staging.js:25:5
    at ChildProcess.exithandler (child_process.js:202:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:501:12)

custom-commmit/cli.js

#!/usr/bin/env node

const path = require('path');
const bootstrap = require('commitizen/dist/cli/git-cz').bootstrap;

bootstrap({
  cliPath: path.join(__dirname, 'node_modules/commitizen'),
  config: {
    path: '@mycompany/cz-custom-changelog'
  }
});

@mycompany/cz-custom-changelog is a dependency of custom-commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions