Skip to content

Commit 9bc76a6

Browse files
authored
fix no git repo error (#92)
* fix no git repo error * Add encoding to tests * trim project root
1 parent 8be63a6 commit 9bc76a6

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"it",
7373
"describe",
7474
"beforeEach",
75-
"afterEach"
75+
"afterEach",
76+
"jest"
7677
]
7778
}
7879
}

src/helpers/files.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ function fetchGitRoot () {
7979
try {
8080
return (
8181
childProcess
82-
.spawnSync('git', ['rev-parse', '--show-toplevel'])
83-
.stdout.toString()
84-
.trimRight() ||
82+
.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8' })
83+
.stdout ||
8584
childProcess
86-
.spawnSync('hg', ['root'])
87-
.stdout.toString()
88-
.trimRight() ||
85+
.spawnSync('hg', ['root'], { encoding: 'utf-8' })
86+
.stdout ||
8987
process.cwd()
90-
)
88+
).trimRight()
9189
} catch (error) {
9290
throw new Error('Error fetching git root. Please try using the -R flag.')
9391
}

src/helpers/web.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ async function uploadToCodecov (uploadURL, token, query, uploadFile, version) {
6868
}
6969
}
7070

71-
72-
function camelToSnake(str) {
71+
function camelToSnake (str) {
7372
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)
74-
.map(s => s.toLowerCase())
75-
.join('_')
73+
.map(s => s.toLowerCase())
74+
.join('_')
7675
}
7776

7877
function generateQuery (queryParams) {

test/helpers/files.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('File Helpers', () => {
2222
const cwd = td.replace(process, 'cwd')
2323
const spawnSync = td.replace(childProcess, 'spawnSync')
2424
td.when(cwd()).thenReturn({ stdout: 'fish' })
25-
td.when(spawnSync('git', ['rev-parse', '--show-toplevel'])).thenReturn({ stdout: 'gitRoot' })
25+
td.when(spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding:'utf-8' })).thenReturn({ stdout: 'gitRoot' })
2626

2727
expect(fileHelpers.fetchGitRoot()).toBe('gitRoot')
2828
})

test/helpers/validate.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ describe('Input Validators', function () {
1111
})
1212

1313
describe('Flags', function () {
14-
1514
it('Should pass without a dash', function () {
1615
expect(validate.validateFlags('moo')).toBe(true)
1716
})

test/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('Uploader Core', function () {
105105
const result = await app.main({
106106
token: 'abcdefg',
107107
url: 'https://codecov.io',
108-
parent,
108+
parent
109109
})
110110
expect(result).toEqual({ status: 'success', resultURL: 'https://results.codecov.io' })
111111
}, 30000)
@@ -117,7 +117,7 @@ describe('Uploader Core', function () {
117117
name: 'customname',
118118
token: 'abcdefg',
119119
url: 'https://codecov.io',
120-
dryRun: true,
120+
dryRun: true
121121
})
122122
expect(log).toHaveBeenCalledWith(expect.stringMatching(/An example coverage root file/))
123123
expect(log).toHaveBeenCalledWith(expect.stringMatching(/An example coverage other file/))

0 commit comments

Comments
 (0)