commitizen / commitizen/cz-cli

Issue with entry script version

Abierto
#424 1 comentario 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
JavaScript
Estrellas
17.5k
Forks
566
Merge medio
8 h 16 min
PR fusionados (30 d)
1

Descripción

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. (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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con custom-commit/cli.js y compara el diseño instalado mediante npm con el diseño de npm link mostrado en el informe. Lee commitizen/dist/cli/git-cz.js alrededor de la llamada de bootstrap y commitizen/dist/common/util.js; después, reproduce el problema con una instalación empaquetada. Se considera completado cuando el script de entrada se ejecuta sin el ENOENT ni el error de versión posterior.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
cli
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.