Seb*_*anR 4 continuous-integration prettier github-actions
我目前正在将 CI 管道从 CircleCI 迁移到 GitHub Actions,但我遇到了 Prettier 问题。我们使用 Prettier 在我们的项目中强制执行一致的代码风格,这是 CI 管道中的一个步骤。该管道在 Linux、MacOS 和 Windows 上运行。
我执行npx prettier --check "{src,test,examples}/**/*.ts"检查文件是否存在格式问题。奇怪的是,这个检查在 ubuntu-latest 和 macos-latest 上通过,但在 windows-latest 上失败。
您可以在此处查看 windows-latest 的示例输出:
Run npm run format:check
> h5p-nodejs-library@2.0.0 format:check D:\a\H5P-Nodejs-library\H5P-Nodejs-library
> npx prettier --check "{src,test,examples}/**/*.ts"
Checking formatting...
test\TemporaryFileManager.test.ts
[... nearly all our files...]
Code style issues found in the above file(s). Forgot to run Prettier?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! h5p-nodejs-library@2.0.0 format:check: `npx prettier --check "{src,test,examples}/**/*.ts"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the h5p-nodejs-library@2.0.0 format: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! C:\npm\cache\_logs\2020-05-22T14_42_05_193Z-debug.log
##[error]Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
(有关完整日志,请参阅https://github.com/Lumieducation/H5P-Nodejs-library/runs/699946934?check_suite_focus=true )
Prettier 在 Windows 上的行为是否有所不同?我的主开发机器运行 Windows 10,并通过了更漂亮的检查...有人知道检查失败的原因吗?
我找到了问题的原因:这是 Git 在 Windows Server 上检查行结尾的方式。答案可以在: https: //github.com/prettier/prettier/issues/7825找到。
解决方案:添加* text=auto eol=lf到存储库的.gitattributes文件中。
| 归档时间: |
|
| 查看次数: |
3151 次 |
| 最近记录: |