Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 1fff4dc

Browse files
victorhqceddiemoore
authored andcommittedAug 21, 2018
Allow custom yaml file. (#107)
* Add tests for custom `yaml` * Allow custom `yaml` file * Cleans missing variable * Add `yml` as cli argument. * rename `yml` cli argument to `y` This to keep it consistent. * Updates `bin` to receive `y` argument * Rename `y` cli back to `yml`. Added short name as `y`
1 parent 77d7a5e commit 1fff4dc

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed
 

‎bin/codecov

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var args = argv.option([
2020
{name: 'slug', short: 'r', type: 'string', description: "Specify repository slug for Enterprise ex. owner/repo"},
2121
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
2222
{name: 'flags', short: 'F', type: 'string', description: "Codecov Flags"},
23-
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"}
23+
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"},
24+
{name: 'yml', short: 'y', type: 'string', description: "Configuration file Used to specify the location of the .codecov.yml config file. Defaults to codecov.yml and .codecov.yml"}
2425
]).run();
2526

2627
codecov.upload(args);

‎lib/codecov.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ var upload = function(args, on_success, on_failure) {
240240
'https://codecov.io'
241241
var query = {}
242242
var debug = []
243+
var yamlFile =
244+
args.options.yml ||
245+
process.env.codecov_yml ||
246+
process.env.CODECOV_YML ||
247+
'codecov.yml'
243248

244249
console.log(
245250
'' +
@@ -253,7 +258,7 @@ var upload = function(args, on_success, on_failure) {
253258
version
254259
)
255260

256-
query.yaml = ['codecov.yml', '.codecov.yml'].reduce(function(result, file) {
261+
query.yaml = [yamlFile, '.codecov.yml'].reduce(function(result, file) {
257262
return (
258263
result ||
259264
(fs.existsSync(path.resolve(process.cwd(), file)) ? file : undefined)

‎test/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,35 @@ describe('Codecov', function() {
161161
var version = require('../package.json').version
162162
expect(codecov.version).to.eql('v' + version)
163163
})
164+
165+
it('Should use codecov.yml via env variable', function() {
166+
expect(
167+
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
168+
).to.eql('codecov.yml')
169+
170+
fs.writeFileSync('foo.yml', '')
171+
process.env.codecov_yml = 'foo.yml'
172+
expect(
173+
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
174+
).to.eql('foo.yml')
175+
fs.unlinkSync('foo.yml')
176+
delete process.env.codecov_yml
177+
178+
fs.writeFileSync('FOO.yml', '')
179+
process.env.CODECOV_YML = 'FOO.yml'
180+
expect(
181+
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
182+
).to.eql('FOO.yml')
183+
fs.unlinkSync('FOO.yml')
184+
delete process.env.CODECOV_YML
185+
})
186+
187+
it('can get config from cli args', function() {
188+
fs.writeFileSync('foo.yml', '')
189+
var res = codecov.upload({
190+
options: { dump: true, yml: 'foo.yml', disable: 'detect' },
191+
})
192+
expect(res.query.yaml).to.eql('foo.yml')
193+
fs.unlinkSync('foo.yml')
194+
})
164195
})

0 commit comments

Comments
 (0)
This repository has been archived.