improve stacktrace when dangerfile failed to run
- Dominant language
- TypeScript
- Stars
- 5.5k
- Forks
- 381
- Avg merge
- 2h 8m
- Merged PRs (30d)
- 6
Description
for this dangerfile.js
```jsx
import { danger, warn, message } from 'danger';
import fs from 'fs';
// TODO - improve dangerjs
const modifiedMD = danger.git.modified_files.join('\n- ');
const allFiles = danger.git.modified_files.concat(danger.git.created_files);
const includesEdge = allFiles.map(file => {
const reAdd = /\BAdd|Add\B/g;
const reEdge = /\BEdge|Edge\B/g;
const content = fs.readFileSync(file).toString();
const fileHasAMutationAdd = file.match(reAdd);
const fileHaveAnEdge = content.match(reEdge);
fileHasAMutationAdd &&
!fileHaveAnEdge &&
warn(`This file ${file} seems to be an add mutation and not include an output Edge`);
});
message(`Changed Files in this PR: \n - ${modifiedMD}`);
```
it is throwing the following error stacktrace:
```jsx
ENOENT: no such file or directory, open '.github/PULL_REQUEST_TEMPLATE.md'
Error: ENOENT: no such file or directory, open '.github/PULL_REQUEST_TEMPLATE.md'
at Object.fs.openSync (fs.js:660:18)
at Object.fs.readFileSync (fs.js:565:33)
at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
at /app/danger-0.jelc7b1175j.js:18:30
at Object.apply (/app/node_modules/vm2/lib/contextify.js:87:36)
at Array.map ()
at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
at Object. (/app/danger-0.jelc7b1175j.js:14:29)
at NodeVM.run (/app/node_modules/vm2/lib/main.js:427:27)
at Object. (/app/node_modules/danger/distribution/runner/runners/vm2.js:97:37)
at step (/app/node_modules/danger/distribution/runner/runners/vm2.js:40:23)
at Object.next (/app/node_modules/danger/distribution/runner/runners/vm2.js:21:53)
at /app/node_modules/danger/distribution/runner/runners/vm2.js:15:71
at new Promise ()
at __awaiter (/app/node_modules/danger/distribution/runner/runners/vm2.js:11:12)
at Object.exports.runDangerfileEnvironment (/app/node_modules/danger/distribution/runner/runners/vm2.js:80:121)
```
it'd be great to show where in dangerfile the error was thrown
Contributor guide
Assessment
This issue has not been assessed yet.