From 155a75609b82633106e2fe3232e6a87bf8450a4c Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 25 Jul 2022 14:11:06 +0200 Subject: [PATCH] Avoid infinite look finding a node_modules directory --- packages/plugos/environments/node_sandbox.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugos/environments/node_sandbox.ts b/packages/plugos/environments/node_sandbox.ts index e71cceb..fe5f2bf 100644 --- a/packages/plugos/environments/node_sandbox.ts +++ b/packages/plugos/environments/node_sandbox.ts @@ -37,7 +37,11 @@ class NodeWorkerWrapper implements WorkerLike { // Look for the node_modules directory, to be passed to the worker to find e.g. the vm2 module export let nodeModulesDir = __dirname; -while (!fs.existsSync(nodeModulesDir + "/node_modules/vm2")) { + +while ( + !fs.existsSync(nodeModulesDir + "/node_modules/vm2") && + nodeModulesDir !== "/" +) { nodeModulesDir = path.dirname(nodeModulesDir); }