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

npm run prettier:check fails with exit status 1 #2453

Closed
asinyagin opened this issue Feb 22, 2019 · 10 comments
Closed

npm run prettier:check fails with exit status 1 #2453

asinyagin opened this issue Feb 22, 2019 · 10 comments

Comments

@asinyagin
Copy link

asinyagin commented Feb 22, 2019

Description / Steps to reproduce / Feature proposal

Create a new app with lb4 app. Then create a new datasource and a model with some fields.

Or clone the repo https://github.com/asinyagin/lb-prettier-reproduce

Run DEBUG=* npm run prettier:check

Current Behavior

> test@1.0.0 prettier:check /home/techie/apps/lb-prettier-reproduce
> npm run prettier:cli -- -l


> test@1.0.0 prettier:cli /home/techie/apps/lb-prettier-reproduce
> lb-prettier "**/*.ts" "**/*.js" "-l"

  loopback:build /home/techie/apps/lb-prettier-reproduce/.prettierrc found +0ms
  loopback:build /home/techie/apps/lb-prettier-reproduce/node_modules/prettier/bin-prettier.js --config-precedence prefer-file --config /home/techie/apps/lb-prettier-reproduce/.prettierrc **/*.ts **/*.js -l +4ms
  loopback:build Spawn /home/techie/.nvm/versions/node/v11.9.0/bin/node /home/techie/apps/lb-prettier-reproduce/node_modules/prettier/bin-prettier.js --config-precedence prefer-file --config /home/techie/apps/lb-prettier-reproduce/.prettierrc **/*.ts **/*.js -l +1ms
src/models/user.model.ts
  loopback:build /home/techie/apps/lb-prettier-reproduce/node_modules/prettier/bin-prettier.js exits: 1 +1s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 prettier:cli: `lb-prettier "**/*.ts" "**/*.js" "-l"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 prettier:cli script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/techie/.npm/_logs/2019-02-22T08_18_49_757Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 prettier:check: `npm run prettier:cli -- -l`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 prettier:check script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/techie/.npm/_logs/2019-02-22T08_18_49_791Z-debug.log

Expected Behavior

It should run without errors.

If I run the prettier command it exits with code 0:

$ /home/techie/.nvm/versions/node/v11.9.0/bin/node /home/techie/apps/lb-prettier-reproduce/node_modules/prettier/bin-prettier.js --config-precedence prefer-file --config /home/techie/apps/lb-prettier-reproduce/.prettierrc **/*.ts **/*.js -l
$ echo $?
0

There is a simlar issue #1045, but I'm using the latest release.

$ lb4 --version
@loopback/cli version: 1.6.0

@loopback/* dependencies:
  - @loopback/authentication: ^1.0.12
  - @loopback/boot: ^1.0.12
  - @loopback/build: ^1.3.0
  - @loopback/context: ^1.5.1
  - @loopback/core: ^1.1.6
  - @loopback/metadata: ^1.0.6
  - @loopback/openapi-spec-builder: ^1.0.6
  - @loopback/openapi-v3-types: ^1.0.6
  - @loopback/openapi-v3: ^1.2.1
  - @loopback/repository-json-schema: ^1.3.1
  - @loopback/repository: ^1.1.5
  - @loopback/rest: ^1.5.5
  - @loopback/testlab: ^1.0.6
  - @loopback/docs: ^1.7.3
  - @loopback/example-hello-world: ^1.1.3
  - @loopback/example-log-extension: ^1.1.3
  - @loopback/example-rpc-server: ^1.1.2
  - @loopback/example-todo: ^1.4.3
  - @loopback/example-soap-calculator: ^1.3.3
  - @loopback/service-proxy: ^1.0.8
  - @loopback/http-caching-proxy: ^1.0.6
  - @loopback/http-server: ^1.1.5
  - @loopback/example-todo-list: ^1.4.3
  - @loopback/dist-util: ^0.4.0
  - @loopback/rest-explorer: ^1.1.8
  - @loopback/tslint-config: ^2.0.0
@raymondfeng
Copy link
Contributor

If you specify --format option for the commands, the project will be reformatted after each command.

@juleskreutzer
Copy link

I'm having the same issues when I run npm run test .

I made sure that I have updated my packages. You mention that I should use the --format option, but my question is, where? 😅


lb4 -v
@loopback/cli version: 1.8.4

@loopback/* dependencies:
  - @loopback/authentication: ^1.0.17
  - @loopback/boot: ^1.1.2
  - @loopback/build: ^1.4.0
  - @loopback/context: ^1.8.1
  - @loopback/core: ^1.2.1
  - @loopback/metadata: ^1.0.10
  - @loopback/openapi-spec-builder: ^1.1.2
  - @loopback/openapi-v3-types: ^1.0.10
  - @loopback/openapi-v3: ^1.3.2
  - @loopback/repository-json-schema: ^1.3.6
  - @loopback/repository: ^1.2.1
  - @loopback/rest: ^1.9.1
  - @loopback/testlab: ^1.2.1
  - @loopback/docs: ^1.11.1
  - @loopback/example-hello-world: ^1.1.8
  - @loopback/example-log-extension: ^1.1.8
  - @loopback/example-rpc-server: ^1.1.7
  - @loopback/example-todo: ^1.5.3
  - @loopback/example-soap-calculator: ^1.4.3
  - @loopback/service-proxy: ^1.1.1
  - @loopback/http-caching-proxy: ^1.0.11
  - @loopback/http-server: ^1.1.10
  - @loopback/example-todo-list: ^1.5.3
  - @loopback/dist-util: ^0.4.0
  - @loopback/rest-explorer: ^1.1.13
  - @loopback/tslint-config: ^2.0.3
  - @loopback/example-express-composition: ^1.2.3

@raymondfeng
Copy link
Contributor

All lb4 commands accept —format

@raymondfeng
Copy link
Contributor

raymondfeng commented Mar 31, 2019

You can also run npm run lint:fix

@eric-jesover
Copy link

@raymondfeng not sure to understand the workaround
npm run prettier:check is failing for me
I just want to make the check not do any reformating like with --format

@raymondfeng
Copy link
Contributor

@eric-jesover The --format flag triggers npm run prettier:fix after the command finishes its work.

npm run prettier:check verifies if the code is formatted based on prettier rules. It does not reformat anything.

npm run prettier:fix reformats your code. Afterward, npm run prettier:check will passs.

If you don't care formatting, you can remove such scripts from package.json.

@eric-jesover
Copy link

@raymondfeng yes understood that, thanks for the clarification
The underline question is "what to do to have 'npm run prettier:check' running without error?"

@raymondfeng
Copy link
Contributor

npm run prettier:check passes if all files are formatted per prettier rules. You can use npm run pretter:fix to fix formatting issues.

@OlivierDupre
Copy link

Thanks a lot @raymondfeng You made my day.

By the way, that is a pretty strange behavior. I would expect prettier to list issues, not to fail without any hint.

But this is a completely different topic and has nothing to do with Loopback.

Thanks again.

@tuanquynet
Copy link

Yup, I expect it should tell me what is going wrong.

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

6 participants