diff --git a/package.json b/package.json index 9033a082e..3b5f7e0cb 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,8 @@ "it", "describe", "beforeEach", - "afterEach" + "afterEach", + "jest" ] } } diff --git a/src/helpers/files.js b/src/helpers/files.js index ea53e9941..a55ac352d 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -79,15 +79,13 @@ function fetchGitRoot () { try { return ( childProcess - .spawnSync('git', ['rev-parse', '--show-toplevel']) - .stdout.toString() - .trimRight() || + .spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8' }) + .stdout || childProcess - .spawnSync('hg', ['root']) - .stdout.toString() - .trimRight() || + .spawnSync('hg', ['root'], { encoding: 'utf-8' }) + .stdout || process.cwd() - ) + ).trimRight() } catch (error) { throw new Error('Error fetching git root. Please try using the -R flag.') } diff --git a/src/helpers/web.js b/src/helpers/web.js index b88d5fd36..a872e7f2d 100644 --- a/src/helpers/web.js +++ b/src/helpers/web.js @@ -68,11 +68,10 @@ async function uploadToCodecov (uploadURL, token, query, uploadFile, version) { } } - -function camelToSnake(str) { +function camelToSnake (str) { return str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(s => s.toLowerCase()) - .join('_') + .map(s => s.toLowerCase()) + .join('_') } function generateQuery (queryParams) { diff --git a/test/helpers/files.test.js b/test/helpers/files.test.js index 7e327d65a..85d74c60e 100644 --- a/test/helpers/files.test.js +++ b/test/helpers/files.test.js @@ -22,7 +22,7 @@ describe('File Helpers', () => { const cwd = td.replace(process, 'cwd') const spawnSync = td.replace(childProcess, 'spawnSync') td.when(cwd()).thenReturn({ stdout: 'fish' }) - td.when(spawnSync('git', ['rev-parse', '--show-toplevel'])).thenReturn({ stdout: 'gitRoot' }) + td.when(spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding:'utf-8' })).thenReturn({ stdout: 'gitRoot' }) expect(fileHelpers.fetchGitRoot()).toBe('gitRoot') }) diff --git a/test/helpers/validate.test.js b/test/helpers/validate.test.js index 72c41d15e..08b1190f6 100644 --- a/test/helpers/validate.test.js +++ b/test/helpers/validate.test.js @@ -11,7 +11,6 @@ describe('Input Validators', function () { }) describe('Flags', function () { - it('Should pass without a dash', function () { expect(validate.validateFlags('moo')).toBe(true) }) diff --git a/test/index.test.js b/test/index.test.js index 108f7766c..f0006e5ab 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -105,7 +105,7 @@ describe('Uploader Core', function () { const result = await app.main({ token: 'abcdefg', url: 'https://codecov.io', - parent, + parent }) expect(result).toEqual({ status: 'success', resultURL: 'https://results.codecov.io' }) }, 30000) @@ -117,7 +117,7 @@ describe('Uploader Core', function () { name: 'customname', token: 'abcdefg', url: 'https://codecov.io', - dryRun: true, + dryRun: true }) expect(log).toHaveBeenCalledWith(expect.stringMatching(/An example coverage root file/)) expect(log).toHaveBeenCalledWith(expect.stringMatching(/An example coverage other file/))