Explorar o código

Fall back to looking in node_modules folder in cwd

Alex Dima %!s(int64=5) %!d(string=hai) anos
pai
achega
2ea08783c2
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      src/index.ts

+ 5 - 1
src/index.ts

@@ -28,7 +28,11 @@ featuresArr.forEach(feature => featuresById[feature.label] = feature);
  * Return a resolved path for a given Monaco file.
  */
 function resolveMonacoPath(filePath: string): string {
-  return require.resolve(path.join(process.cwd(), 'node_modules', 'monaco-editor/esm', filePath));
+  try {
+    return require.resolve(path.join('monaco-editor/esm', filePath));
+  } catch(err) {
+    return require.resolve(path.join(process.cwd(), 'node_modules/monaco-editor/esm', filePath));
+  }
 }
 
 /**