From 03ab08d38f95f07d2ea0d4ff48d86e214412a92d Mon Sep 17 00:00:00 2001 From: Scott Gunther Date: Tue, 22 Jun 2021 10:41:32 -0400 Subject: [PATCH] fix: warn on EPERM for project directory just like EACCES (#16934) --- CONTRIBUTING.md | 2 +- packages/server/lib/util/settings.js | 2 +- packages/server/test/unit/project_spec.js | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 50e5aca1cb..965beb223a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,7 +167,7 @@ Search [all issues](https://github.com/cypress-io/cypress/issues) for keywords f If an issue already exists you should: - Thank them for their contribution. -- Explain that this issue if a duplicate of another issue, linking to the relevant issue (`#1234`). +- Explain that this issue is a duplicate of another issue, linking to the relevant issue (`#1234`). - Add the `type: duplicate` label to the issue. - Close the issue. diff --git a/packages/server/lib/util/settings.js b/packages/server/lib/util/settings.js index 8d0280698a..c1d03d1f4d 100644 --- a/packages/server/lib/util/settings.js +++ b/packages/server/lib/util/settings.js @@ -125,7 +125,7 @@ module.exports = { log('cannot find file %s', file) return this._err('CONFIG_FILE_NOT_FOUND', this.configFile(options), projectRoot) - }).catch({ code: 'EACCES' }, () => { + }).catch({ code: 'EACCES' }, { code: 'EPERM' }, () => { // we cannot write due to folder permissions return errors.warning('FOLDER_NOT_WRITABLE', projectRoot) }).catch((err) => { diff --git a/packages/server/test/unit/project_spec.js b/packages/server/test/unit/project_spec.js index 5ef047b3c1..8db2c721d9 100644 --- a/packages/server/test/unit/project_spec.js +++ b/packages/server/test/unit/project_spec.js @@ -806,7 +806,7 @@ This option will not have an effect in Some-other-name. Tests that rely on web s }) }) - it('bubbles up Settings.read errors', function () { + it('bubbles up Settings.read EACCES error', function () { const err = new Error() err.code = 'EACCES' @@ -820,6 +820,21 @@ This option will not have an effect in Some-other-name. Tests that rely on web s expect(err.code).to.eq('EACCES') }) }) + + it('bubbles up Settings.read EPERM error', function () { + const err = new Error() + + err.code = 'EPERM' + + sinon.stub(settings, 'read').rejects(err) + + return this.project.getProjectId() + .then((id) => { + throw new Error('expected to fail, but did not') + }).catch((err) => { + expect(err.code).to.eq('EPERM') + }) + }) }) context('#writeProjectId', () => {