Skip to content

Commit

Permalink
fallback to own request module (#1650)
Browse files Browse the repository at this point in the history
- closes #1649
  • Loading branch information
foxriver76 authored Jul 27, 2024
1 parent 74257ba commit 57299d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Executes Javascript, Typescript Scripts.
<!--
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**
* (foxriver76) added fallback to require the adapters `request` module if no own installed

### 8.7.3 (2024-07-25)
* (@klein0r) Fixed script deletion (icon was missing)
* (@klein0r) Fixed some translations and Blockly definitions
Expand Down
9 changes: 7 additions & 2 deletions lib/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,16 @@ function sandBox(script, name, verbose, debug, context) {
md = md.replace(/^node:/, '');
}

if (typeof md === 'string') {
if (md === 'request' && !sandbox.__engine.__deprecatedWarnings.includes(md)) {
if (md === 'request') {
if (!sandbox.__engine.__deprecatedWarnings.includes(md)) {
sandbox.log(`request package is deprecated - please use httpGet (or a stable lib like axios) instead!`, 'warn');
sandbox.__engine.__deprecatedWarnings.push(md);
}

if (!mods[md]) {
// for backward compatibility we require the adapters own request module as back in the days this module did not need to be specified in the additional npm modules
mods[md] = require(md);
}
}

if (mods[md]) {
Expand Down

0 comments on commit 57299d9

Please sign in to comment.