Is it possible to include code from another module into your dangerfile.js
or dangerfile.ts
? Specifically I mean your code, not some dependency defined in your package.json.
I've tried it with a few different styles of include/require in both JS and TS and couldn't get it to work.
Ex of how I've tried to import it (silly naming to make it more clear and also I've tried using import
rather than require
):
const myDangerLib = require('./danger/lib');
I keep getting errors like this:
Unable to evaluate the Dangerfile
7
ReferenceError: myDangerLib is not defined
8
at Object.<anonymous> (dangerfile.ts:6:11)
Weird thing is that it looks from the docker run
command output from the GitHub Action that I'm using like the whole repo is mounted into the container, so I don't know why my lib file would be not found. Here's my GitHub Action step:
- name: Danger
uses: danger/danger-js@9.1.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Any ideas why this is not working? Or is it just not possible to include code from another one of your modules with DangerJS?
Thanks