-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with importing Danger module in Dangerfile.js #1459
Comments
I assume then you don't have babel or typescript in your repo which would remove those imports I think, they are largely ceremonial and only exist to ensure a reasonable dev experience - they are actually globals, so you're OK to just write |
I confirm @orta’s statements, in JS-alone, you can either remove the To elaborate: When I last tweaked the relevant code in DangerJS, As you mentioned, we definitely should update things to no longer reference the Spectrum link, as Spectrum is defunct for us. |
This file is supposed to strip the import out: Some relevant call sites: danger-js/source/runner/runners/inline.ts Line 95 in 92d2525
danger-js/source/platforms/GitHub.ts Line 145 in 92d2525
|
One question: you’re not just trying to (Danger has a CLI tool that you use to trigger it that ensures all the environmental conditions are right for your code to be executed correctly!) |
sorry for late response. it logs like Hey there, it looks like you're trying to import the danger module. Turns out When running Danger, the import or require for Danger is removed before the code There is a spectrum thread for discussion here: (Use Node.js v20.11.0 |
I'm encountering an error when trying to import the Danger module in my Dangerfile.js. Additionally, the provided Spectrum discussion thread link (https://spectrum.chat/?t=0a005b56-31ec-4919-9a28-ced623949d4d) is broken and returns a 404 error.
Error Message:
throw "\nHey there, it looks like you're trying to import the danger module. Turns out\nthat the code you write in a Dangerfile.js is actually a bit of a sneaky hack. \n\nWhen running Danger, the import or require for Danger is removed before the code\nis evaluated. Instead all of the imports are added to the global runtime, so if\nyou are importing Danger to use one of it's functions - you should instead just\nuse the global object for the root DSL elements.\n\nThere is a spectrum thread for discussion here:\n - https://spectrum.chat/?t=0a005b56-31ec-4919-9a28-ced623949d4d\n";
^
Hey there, it looks like you're trying to import the danger module. Turns out
that the code you write in a Dangerfile.js is actually a bit of a sneaky hack.
When running Danger, the import or require for Danger is removed before the code
is evaluated. Instead all of the imports are added to the global runtime, so if
you are importing Danger to use one of it's functions - you should instead just
use the global object for the root DSL elements.
There is a spectrum thread for discussion here:
(Use
node --trace-uncaught ...
to show where the exception was thrown)Node.js v20.11.0
Steps to Reproduce:
`import { danger, markdown, message, warn } from 'danger';
// Example usage of danger
markdown('This is a markdown message');`
Expected Behavior:
The Danger.js script should run without throwing an import error, and the appropriate actions should be executed as specified in the Dangerfile.js.
Actual Behavior:
The script throws an error indicating that importing the Danger module is not allowed. Additionally, the provided link to the Spectrum discussion thread is broken and returns a 404 error.
Environment:
Node.js version: v20.11.0
Danger.js version: [Specify the version you are using]
Additional Context:
The error suggests that the import for Danger is removed before the code is evaluated, and all imports are added to the global runtime instead. However, there is no clear documentation on this behavior, and the broken Spectrum link makes it difficult to find further information or discussion on the topic.
Please provide guidance on how to properly use Danger.js with Node.js v20.11.0 and any updates on the broken Spectrum thread link.
The text was updated successfully, but these errors were encountered: