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

Commit c0711c6

Browse files
drazisilGuillaume St-Pierre
and
Guillaume St-Pierre
authored
Switch from execSync to execFileSync (#180)
* Switch from execSync to execFileSync * Call existsSync instead of executing `if` * Trigger a build * I think this fixes linux and macos... * Only add more_patterns of it has a value. Correct windows. * Remove default value to more_patterns, change windows to winPatterns * Try a colon. * Let's try not using MinGw... * What are the chances that Windows has a find? * Put it back * Reverting Windows side so this can me merged in time if needed. * Reverting Windows side so this can me merged in time if needed. * Update lib/codecov.js Co-authored-by: Guillaume St-Pierre <guillaume@codecov.io> * Update lib/codecov.js Co-authored-by: Guillaume St-Pierre <guillaume@codecov.io> * Set initial values Co-authored-by: Guillaume St-Pierre <guillaume@codecov.io>
1 parent 5f6cc62 commit c0711c6

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.idea/.gitignore

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,5 @@ If you're seeing an **HTTP 400 error when uploading reports to S3**, make sure y
116116
- v3.6.3 Fix for AWS Codebuild & package updates
117117
- v3.6.4 Fix Cirrus CI
118118
- v3.7.0 Remove the X-Amz-Acl: public-read header
119+
120+
.

lib/codecov.js

+37-18
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ var request = require('teeny-request').teenyRequest
44
var urlgrey = require('urlgrey')
55
var jsYaml = require('js-yaml')
66
var walk = require('ignore-walk')
7+
var execFileSync = require('child_process').execFileSync
78
var execSync = require('child_process').execSync
89

910
var detectProvider = require('./detect')
1011

1112
var version = 'v' + require('../package.json').version
1213

13-
var patterns,
14-
more_patterns = ''
14+
var patterns = ''
15+
var more_patterns = ''
16+
var winPatterns = ''
1517

1618
var isWindows =
1719
process.platform.match(/win32/) || process.platform.match(/win64/)
1820

1921
if (!isWindows) {
20-
patterns =
21-
"-type f \\( -name '*coverage.*' " +
22+
patterns = (
23+
"-type f -name '*coverage.*' " +
2224
"-or -name 'nosetests.xml' " +
2325
"-or -name 'jacoco*.xml' " +
2426
"-or -name 'clover.xml' " +
@@ -29,7 +31,7 @@ if (!isWindows) {
2931
"-or -name '*.lcov' " +
3032
"-or -name 'gcov.info' " +
3133
"-or -name '*.gcov' " +
32-
"-or -name '*.lst' \\) " +
34+
"-or -name '*.lst' " +
3335
"-not -name '*.sh' " +
3436
"-not -name '*.data' " +
3537
"-not -name '*.py' " +
@@ -76,9 +78,10 @@ if (!isWindows) {
7678
"-not -path '*/$bower_components/*' " +
7779
"-not -path '*/node_modules/*' " +
7880
"-not -path '*/conftest_*.c.gcov'"
81+
).split(' ')
7982
} else {
80-
patterns =
81-
'/a-d /b /s *coverage.* ' +
83+
winPatterns = (
84+
'/a:-d /b /s *coverage.* ' +
8285
'/s nosetests.xml ' +
8386
'/s jacoco*.xml ' +
8487
'/s clover.xml ' +
@@ -136,6 +139,7 @@ if (!isWindows) {
136139
'| findstr /i /v \\\\$bower_components\\ ' +
137140
'| findstr /i /v \\node_modules\\ ' +
138141
'| findstr /i /v \\conftest_.*\\.c\\.gcov '
142+
).split(' ')
139143
}
140144

141145
var sendToCodecovV2 = function(
@@ -355,7 +359,7 @@ var upload = function(args, on_success, on_failure) {
355359
console.log('==> Building file structure')
356360
try {
357361
upload +=
358-
execSync('git ls-files || hg locate', { cwd: root })
362+
execFileSync('git', ['ls-files', '||', 'hg', 'locate'], { cwd: root })
359363
.toString()
360364
.trim() + '\n<<<<<< network\n'
361365
} catch (err) {
@@ -414,7 +418,7 @@ var upload = function(args, on_success, on_failure) {
414418
}
415419
debug.push(gcov)
416420
console.log(' $ ' + gcov)
417-
execSync(gcov)
421+
execFileSync(gcov)
418422
} catch (e) {
419423
console.log(' Failed to run gcov command.')
420424
}
@@ -431,19 +435,23 @@ var upload = function(args, on_success, on_failure) {
431435
.toString()
432436
.trim()
433437
} else {
434-
bowerrc = execSync('if exist .bowerrc type .bowerrc', { cwd: root })
435-
.toString()
436-
.trim()
438+
bowerrc = fs.existsSync('.bowerrc')
437439
}
438440
if (bowerrc) {
439441
bowerrc = JSON.parse(bowerrc).directory
440442
if (bowerrc) {
441443
if (!isWindows) {
442-
more_patterns =
443-
" -not -path '*/" + bowerrc.toString().replace(/\/$/, '') + "/*'"
444+
more_patterns = (
445+
" -not -path '*/" +
446+
bowerrc.toString().replace(/\/$/, '') +
447+
"/*'"
448+
).split(' ')
444449
} else {
445-
more_patterns =
446-
'| findstr /i /v \\' + bowerrc.toString().replace(/\/$/, '') + '\\'
450+
more_patterns = (
451+
'| findstr /i /v \\' +
452+
bowerrc.toString().replace(/\/$/, '') +
453+
'\\'
454+
).split(' ')
447455
}
448456
}
449457
}
@@ -474,15 +482,26 @@ var upload = function(args, on_success, on_failure) {
474482
} else if ((args.options.disable || '').split(',').indexOf('search') === -1) {
475483
console.log('==> Scanning for reports')
476484
var _files
485+
var _findArgs
477486
if (!isWindows) {
478-
_files = execSync('find ' + root + ' ' + patterns + more_patterns)
487+
// @TODO support for a root directory
488+
// It's not straightforward due to the nature of the find command
489+
_findArgs = [root].concat(patterns)
490+
if (more_patterns) {
491+
_findArgs.concat(more_patterns)
492+
}
493+
_files = execFileSync('find', _findArgs)
479494
.toString()
480495
.trim()
481496
.split('\n')
482497
} else {
483498
// @TODO support for a root directory
484499
// It's not straightforward due to the nature of the dir command
485-
_files = execSync('dir ' + patterns + more_patterns)
500+
_findArgs = [root].concat(winPatterns)
501+
if (more_patterns) {
502+
_findArgs.concat(more_patterns)
503+
}
504+
_files = execSync('dir ' + winPatterns.join(' ') + more_patterns)
486505
.toString()
487506
.trim()
488507
.split('\r\n')

0 commit comments

Comments
 (0)