GitHub 操作:Prettier 仅在 windows-latest 上发现错误
GitHub Actions: Prettier finds errors only on windows-latest
我目前正在将我们的 CI 管道从 CircleCI 转移到 GitHub Actions,我在使用 Prettier 时遇到了问题。我们使用 Prettier 在我们的项目中强制执行一致的代码风格,这是 CI 管道中的一个步骤。该管道在 Linux、MacOS 和 Windows 上运行。
我执行 npx prettier --check "{src,test,examples}/**/*.ts"
来检查文件是否存在格式问题。奇怪的是,此检查通过 ubuntu-latest 和 macos-latest,但在 windows-latest.
上失败
您可以在此处查看 windows-最新的示例输出:
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\_logs20-05-22T14_42_05_193Z-debug.log
##[error]Process completed with exit code 1.
(完整日志请参阅 https://github.com/Lumieducation/H5P-Nodejs-library/runs/699946934?check_suite_focus=true)
Prettier 在 Windows 上的表现是否不同?我的主要开发机器运行 Windows 10 一个更漂亮的检查通过了...有没有人知道检查失败的原因?
我找到了问题的原因:这是 Git 在 Windows 服务器上检查行尾的方式。可以在以下位置找到答案:https://github.com/prettier/prettier/issues/7825.
解决方案:将 * text=auto eol=lf 添加到 repo 的 .gitattributes 文件中。
我目前正在将我们的 CI 管道从 CircleCI 转移到 GitHub Actions,我在使用 Prettier 时遇到了问题。我们使用 Prettier 在我们的项目中强制执行一致的代码风格,这是 CI 管道中的一个步骤。该管道在 Linux、MacOS 和 Windows 上运行。
我执行 npx prettier --check "{src,test,examples}/**/*.ts"
来检查文件是否存在格式问题。奇怪的是,此检查通过 ubuntu-latest 和 macos-latest,但在 windows-latest.
您可以在此处查看 windows-最新的示例输出:
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\_logs20-05-22T14_42_05_193Z-debug.log
##[error]Process completed with exit code 1.
(完整日志请参阅 https://github.com/Lumieducation/H5P-Nodejs-library/runs/699946934?check_suite_focus=true)
Prettier 在 Windows 上的表现是否不同?我的主要开发机器运行 Windows 10 一个更漂亮的检查通过了...有没有人知道检查失败的原因?
我找到了问题的原因:这是 Git 在 Windows 服务器上检查行尾的方式。可以在以下位置找到答案:https://github.com/prettier/prettier/issues/7825.
解决方案:将 * text=auto eol=lf 添加到 repo 的 .gitattributes 文件中。