import { danger, message, warn, fail } from 'danger'
var exec = require('child_process').execSync
var _ = require('lodash')
var result;
try {
result = exec("swiftlint lint --quiet --reporter json").stdout.toString()
} catch(ex) {
result = ex.stdout.toString()
}
var json = JSON.parse(result)
json.forEach(finding => {
if (finding.severity == undefined || finding.reason == undefined) {
return
}
var severity = _.toLower(finding.severity)
if (severity == "warning" && finding.reason) {
warn(finding.reason)
} else if (severity == "error" && finding.reason) {
fail(finding.reason)
}
})
The error:
Error: TypeError: Cannot read property 'length' of undefined
at Executor.<anonymous> (.../node_modules/danger/distribution/runner/Executor.js:191:31)
at step (.../node_modules/danger/distribution/runner/Executor.js:32:23)
at Object.next (.../node_modules/danger/distribution/runner/Executor.js:13:53)
at .../node_modules/danger/distribution/runner/Executor.js:7:71
at new Promise (<anonymous>)
at __awaiter (.../node_modules/danger/distribution/runner/Executor.js:3:12)
at Executor.handleResultsPostingToSTDOUT (.../node_modules/danger/distribution/runner/Executor.js:175:16)
at Executor.<anonymous> (.../node_modules/danger/distribution/runner/Executor.js:160:26)
at step (.../node_modules/danger/distribution/runner/Executor.js:32:23)
at Object.next (.../node_modules/danger/distribution/runner/Executor.js:13:53)
error An unexpected error occurred: "Command failed.
It happens when there is a lot of warns/fails (like in the loop I have in my file).
It happens even if I just use warn("dd") and fail("dd") in the loop.
This is my
dangerfile.js
The error: