@lvce-editor/extension-host-helper-process 0.86.9 → 0.86.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-helper-process",
3
- "version": "0.86.9",
3
+ "version": "0.86.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2,9 +2,16 @@ import { pathToFileURL } from 'node:url'
2
2
  import * as CleanImportError from '../CleanImportError/CleanImportError.js'
3
3
  import { VError } from '../VError/VError.js'
4
4
 
5
+ const windowsPathRegex = /^\/[A-Za-z]:\//
6
+
7
+ export const normalizePath = (path, platform = process.platform) => {
8
+ return platform === 'win32' && windowsPathRegex.test(path) ? path.slice(1) : path
9
+ }
10
+
5
11
  export const importScript = async (path) => {
6
12
  try {
7
- const url = pathToFileURL(path).toString()
13
+ const normalizedPath = normalizePath(path)
14
+ const url = pathToFileURL(normalizedPath).toString()
8
15
  const module = await import(url)
9
16
  return module
10
17
  } catch (error) {
@@ -0,0 +1,14 @@
1
+ import { expect, test } from '@jest/globals'
2
+ import { normalizePath } from './ImportScript.js'
3
+
4
+ test('normalizes a windows drive path with a leading slash', () => {
5
+ expect(normalizePath('/D:/a/git/git/packages/node/src/gitClient.js', 'win32')).toBe('D:/a/git/git/packages/node/src/gitClient.js')
6
+ })
7
+
8
+ test('keeps a windows drive path without a leading slash', () => {
9
+ expect(normalizePath('D:/a/git/git/packages/node/src/gitClient.js', 'win32')).toBe('D:/a/git/git/packages/node/src/gitClient.js')
10
+ })
11
+
12
+ test('keeps a posix path', () => {
13
+ expect(normalizePath('/workspace/git/packages/node/src/gitClient.js', 'linux')).toBe('/workspace/git/packages/node/src/gitClient.js')
14
+ })