zudello-execute-local 1.1.43 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/nodeVM.js +33 -1
package/package.json
CHANGED
package/src/utils/nodeVM.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
const { NodeVM, makeResolverFromLegacyOptions } = require('vm2')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
|
|
5
|
+
const createCustomResolver = (sdkOverridePath) => {
|
|
6
|
+
if (!sdkOverridePath) {
|
|
7
|
+
return undefined
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const absoluteSdkPath = path.resolve(sdkOverridePath)
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(absoluteSdkPath)) {
|
|
13
|
+
console.warn(`[WARN] INTEGRATION_SDK_PATH does not exist: ${absoluteSdkPath}`)
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log(`[INFO] Using SDK override path: ${absoluteSdkPath}`)
|
|
18
|
+
|
|
19
|
+
return (moduleName, fromPath) => {
|
|
20
|
+
if (moduleName === 'zudello-integration-sdk-v1') {
|
|
21
|
+
return absoluteSdkPath
|
|
22
|
+
}
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
}
|
|
2
26
|
|
|
3
27
|
const connectionSdkMapping = {
|
|
4
28
|
netsuite: [{
|
|
@@ -153,6 +177,13 @@ const connectionSdkMapping = {
|
|
|
153
177
|
}
|
|
154
178
|
|
|
155
179
|
const initiateNodeVM = (dirNamePath) => {
|
|
180
|
+
const sdkOverridePath = process.env.INTEGRATION_SDK_PATH
|
|
181
|
+
|
|
182
|
+
const rootPaths = [dirNamePath]
|
|
183
|
+
if (sdkOverridePath) {
|
|
184
|
+
rootPaths.push(path.resolve(sdkOverridePath))
|
|
185
|
+
}
|
|
186
|
+
|
|
156
187
|
return new NodeVM({
|
|
157
188
|
console: 'inherit',
|
|
158
189
|
sandbox: {
|
|
@@ -170,7 +201,7 @@ const initiateNodeVM = (dirNamePath) => {
|
|
|
170
201
|
],
|
|
171
202
|
},
|
|
172
203
|
builtin: ['https'],
|
|
173
|
-
root:
|
|
204
|
+
root: rootPaths,
|
|
174
205
|
import: [
|
|
175
206
|
'lodash',
|
|
176
207
|
'performance-now',
|
|
@@ -179,6 +210,7 @@ const initiateNodeVM = (dirNamePath) => {
|
|
|
179
210
|
'he',
|
|
180
211
|
'zudello-integration-sdk-v1',
|
|
181
212
|
],
|
|
213
|
+
resolve: createCustomResolver(sdkOverridePath),
|
|
182
214
|
mock: {
|
|
183
215
|
fs: {
|
|
184
216
|
readFileSync() {
|