瀏覽代碼

Merge pull request #105 from KevLeong/fix/monaco_path

fix: monaco path by cwd
Alexandru Dima 5 年之前
父節點
當前提交
0c36fc7eb7
共有 1 個文件被更改,包括 5 次插入1 次删除
  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('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));
+  }
 }
 
 /**