From 6aa3a66966affc4f755ac4acf033b8c1caaad5d6 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Sat, 2 Mar 2019 01:53:49 +0100 Subject: [PATCH] Make vs/base/common/path compatible with ESM --- src/vs/base/common/path.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/vs/base/common/path.ts b/src/vs/base/common/path.ts index 53bd495fd8d..982934e20d1 100644 --- a/src/vs/base/common/path.ts +++ b/src/vs/base/common/path.ts @@ -205,12 +205,7 @@ interface IPath { posix: IPath | null; } -interface IExportedPath extends IPath { - win32: IPath; - posix: IPath; -} - -const win32: IPath = { +export const win32: IPath = { // path.resolve([from ...], to) resolve(...pathSegments: string[]): string { let resolvedDevice = ''; @@ -1199,7 +1194,7 @@ const win32: IPath = { posix: null }; -const posix: IPath = { +export const posix: IPath = { // path.resolve([from ...], to) resolve(...pathSegments: string[]): string { let resolvedPath = ''; @@ -1685,5 +1680,16 @@ const posix: IPath = { posix.win32 = win32.win32 = win32; posix.posix = win32.posix = posix; -const impl = (safeProcess.platform === 'win32' ? win32 : posix) as IExportedPath; -export = impl; +export const normalize = (safeProcess.platform === 'win32' ? win32.normalize : posix.normalize); +export const isAbsolute = (safeProcess.platform === 'win32' ? win32.isAbsolute : posix.isAbsolute); +export const join = (safeProcess.platform === 'win32' ? win32.join : posix.join); +export const resolve = (safeProcess.platform === 'win32' ? win32.resolve : posix.resolve); +export const relative = (safeProcess.platform === 'win32' ? win32.relative : posix.relative); +export const dirname = (safeProcess.platform === 'win32' ? win32.dirname : posix.dirname); +export const basename = (safeProcess.platform === 'win32' ? win32.basename : posix.basename); +export const extname = (safeProcess.platform === 'win32' ? win32.extname : posix.extname); +export const format = (safeProcess.platform === 'win32' ? win32.format : posix.format); +export const parse = (safeProcess.platform === 'win32' ? win32.parse : posix.parse); +export const toNamespacedPath = (safeProcess.platform === 'win32' ? win32.toNamespacedPath : posix.toNamespacedPath); +export const sep = (safeProcess.platform === 'win32' ? win32.sep : posix.sep); +export const delimiter = (safeProcess.platform === 'win32' ? win32.delimiter : posix.delimiter); -- GitLab