diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9a68dc792..d76d4f4d4 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3274,9 +3274,7 @@ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, "optional": true, - "os": [ - "darwin" - ], + "os": ["darwin"], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } diff --git a/src/helpers/files.js b/src/helpers/files.js index 637a4748d..32fb3ea6e 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -237,7 +237,7 @@ function getAllFiles(projectRoot, dirPath, args, arrayOfFiles = []) { if (isBlacklisted(projectRoot, file, manualBlacklist())) { return } - if (fs.statSync(path.join(dirPath, file)).isDirectory()) { + if (fs.lstatSync(path.join(dirPath, file)).isDirectory()) { arrayOfFiles = getAllFiles( projectRoot, path.join(dirPath, file), diff --git a/src/helpers/token.js b/src/helpers/token.js index c3f8229ab..053c9d3a0 100644 --- a/src/helpers/token.js +++ b/src/helpers/token.js @@ -50,10 +50,18 @@ function getTokenFromYaml(projectRoot, args) { }) const yamlConfig = yaml.load(fileContents) if ( - yamlConfig['codecov_token'] && - validateHelpers.validateToken(yamlConfig['codecov_token']) + yamlConfig['codecov'] && + yamlConfig['codecov']['token'] && + validateHelpers.validateToken(yamlConfig['codecov']['token']) ) { - return yamlConfig['codecov_token'] + return yamlConfig['codecov']['token'] + } + + if (yamlConfig['codecov_token']) { + error( + `'codecov_token' is a deprecated field. Please switch to 'codecov.token' ` + + '(https://docs.codecov.com/docs/codecovyml-reference#codecovtoken)' + ) } } } catch (err) { diff --git a/test/fixtures/invalid_yaml/codecov.yaml b/test/fixtures/invalid_yaml/codecov.yaml new file mode 100644 index 000000000..70973190f --- /dev/null +++ b/test/fixtures/invalid_yaml/codecov.yaml @@ -0,0 +1 @@ +codecov_token: faketoken diff --git a/test/fixtures/yaml/.codecov.yml b/test/fixtures/yaml/.codecov.yml index d26f19555..36a30ad84 100644 --- a/test/fixtures/yaml/.codecov.yml +++ b/test/fixtures/yaml/.codecov.yml @@ -1 +1,2 @@ -codecov_token: invalid token +codecov: + token: invalid token diff --git a/test/fixtures/yaml/codecov.yaml b/test/fixtures/yaml/codecov.yaml index 70973190f..360245e6f 100644 --- a/test/fixtures/yaml/codecov.yaml +++ b/test/fixtures/yaml/codecov.yaml @@ -1 +1,2 @@ -codecov_token: faketoken +codecov: + token: faketoken diff --git a/test/fixtures/yaml/codecov.yml b/test/fixtures/yaml/codecov.yml index 4e75028d8..ffaf6ebea 100644 --- a/test/fixtures/yaml/codecov.yml +++ b/test/fixtures/yaml/codecov.yml @@ -1 +1,2 @@ -codecov_token: anotherfaketoken +codecov: + token: anotherfaketoken diff --git a/test/helpers/token.test.js b/test/helpers/token.test.js index 210ac41bf..0696b5287 100644 --- a/test/helpers/token.test.js +++ b/test/helpers/token.test.js @@ -1,4 +1,5 @@ const path = require('path') +const { expect, it } = require('@jest/globals') const fileHelpers = require('../../src/helpers/files') const tokenHelpers = require('../../src/helpers/token') @@ -8,7 +9,15 @@ describe('Get tokens', () => { fileHelpers.fetchGitRoot(), 'test/fixtures/yaml', ) - console.log(fixturesDir) + const invalidFixturesDir = path.join( + fileHelpers.fetchGitRoot(), + 'test/fixtures/invalid_yaml', + ) + + afterEach(() => { + jest.clearAllMocks() + }) + describe('From yaml', () => { it('Returns empty with no yaml file', () => { expect(tokenHelpers.getTokenFromYaml('.')).toBe('') @@ -19,6 +28,19 @@ describe('Get tokens', () => { tokenHelpers.getTokenFromYaml(fixturesDir, { verbose: true }), ).toBe('faketoken') }) + + it('Returns deprecation error from codecov_token', () => { + jest.spyOn(console, 'error').mockImplementation(() => { + // Intentionally empty + }) + expect( + tokenHelpers.getTokenFromYaml(invalidFixturesDir, { verbose: true }), + ).toBe('') + + expect(console.error).toHaveBeenCalledWith( + expect.stringContaining("'codecov_token' is a deprecated field"), + ) + }) }) describe('From right source', () => {