2929 * USE OR OTHER DEALINGS IN THE SOFTWARE.
3030 */
3131
32- import { isWindows } from 'vs/base/common/platform ' ;
32+ import * as process from 'vs/base/common/process ' ;
3333
3434const CHAR_UPPERCASE_A = 65 ; /* A */
3535const CHAR_LOWERCASE_A = 97 ; /* a */
@@ -41,19 +41,6 @@ const CHAR_BACKWARD_SLASH = 92; /* \ */
4141const CHAR_COLON = 58 ; /* : */
4242const CHAR_QUESTION_MARK = 63 ; /* ? */
4343
44- interface IProcess {
45- cwd ( ) : string ;
46- platform : string ;
47- env : object ;
48- }
49-
50- declare let process : IProcess ;
51- const safeProcess : IProcess = ( typeof process === 'undefined' ) ? {
52- cwd ( ) { return '/' ; } ,
53- env : { } ,
54- get platform ( ) { return isWindows ? 'win32' : 'posix' ; }
55- } : process ;
56-
5744class ErrorInvalidArgType extends Error {
5845 code : 'ERR_INVALID_ARG_TYPE' ;
5946 constructor ( name : string , expected : string , actual : string ) {
@@ -219,14 +206,14 @@ export const win32: IPath = {
219206 if ( i >= 0 ) {
220207 path = pathSegments [ i ] ;
221208 } else if ( ! resolvedDevice ) {
222- path = safeProcess . cwd ( ) ;
209+ path = process . cwd ( ) ;
223210 } else {
224211 // Windows has the concept of drive-specific current working
225212 // directories. If we've resolved a drive letter but not yet an
226213 // absolute path, get cwd for that drive, or the process cwd if
227214 // the drive cwd is not available. We're sure the device is not
228215 // a UNC path at this points, because UNC paths are always absolute.
229- path = safeProcess . env [ '=' + resolvedDevice ] || safeProcess . cwd ( ) ;
216+ path = process . env [ '=' + resolvedDevice ] || process . cwd ( ) ;
230217
231218 // Verify that a cwd was found and that it actually points
232219 // to our drive. If not, default to the drive's root.
@@ -1208,7 +1195,7 @@ export const posix: IPath = {
12081195 path = pathSegments [ i ] ;
12091196 }
12101197 else {
1211- path = safeProcess . cwd ( ) ;
1198+ path = process . cwd ( ) ;
12121199 }
12131200
12141201 validateString ( path , 'path' ) ;
@@ -1682,16 +1669,16 @@ export const posix: IPath = {
16821669posix . win32 = win32 . win32 = win32 ;
16831670posix . posix = win32 . posix = posix ;
16841671
1685- export const normalize = ( safeProcess . platform === 'win32' ? win32 . normalize : posix . normalize ) ;
1686- export const isAbsolute = ( safeProcess . platform === 'win32' ? win32 . isAbsolute : posix . isAbsolute ) ;
1687- export const join = ( safeProcess . platform === 'win32' ? win32 . join : posix . join ) ;
1688- export const resolve = ( safeProcess . platform === 'win32' ? win32 . resolve : posix . resolve ) ;
1689- export const relative = ( safeProcess . platform === 'win32' ? win32 . relative : posix . relative ) ;
1690- export const dirname = ( safeProcess . platform === 'win32' ? win32 . dirname : posix . dirname ) ;
1691- export const basename = ( safeProcess . platform === 'win32' ? win32 . basename : posix . basename ) ;
1692- export const extname = ( safeProcess . platform === 'win32' ? win32 . extname : posix . extname ) ;
1693- export const format = ( safeProcess . platform === 'win32' ? win32 . format : posix . format ) ;
1694- export const parse = ( safeProcess . platform === 'win32' ? win32 . parse : posix . parse ) ;
1695- export const toNamespacedPath = ( safeProcess . platform === 'win32' ? win32 . toNamespacedPath : posix . toNamespacedPath ) ;
1696- export const sep = ( safeProcess . platform === 'win32' ? win32 . sep : posix . sep ) ;
1697- export const delimiter = ( safeProcess . platform === 'win32' ? win32 . delimiter : posix . delimiter ) ;
1672+ export const normalize = ( process . platform === 'win32' ? win32 . normalize : posix . normalize ) ;
1673+ export const isAbsolute = ( process . platform === 'win32' ? win32 . isAbsolute : posix . isAbsolute ) ;
1674+ export const join = ( process . platform === 'win32' ? win32 . join : posix . join ) ;
1675+ export const resolve = ( process . platform === 'win32' ? win32 . resolve : posix . resolve ) ;
1676+ export const relative = ( process . platform === 'win32' ? win32 . relative : posix . relative ) ;
1677+ export const dirname = ( process . platform === 'win32' ? win32 . dirname : posix . dirname ) ;
1678+ export const basename = ( process . platform === 'win32' ? win32 . basename : posix . basename ) ;
1679+ export const extname = ( process . platform === 'win32' ? win32 . extname : posix . extname ) ;
1680+ export const format = ( process . platform === 'win32' ? win32 . format : posix . format ) ;
1681+ export const parse = ( process . platform === 'win32' ? win32 . parse : posix . parse ) ;
1682+ export const toNamespacedPath = ( process . platform === 'win32' ? win32 . toNamespacedPath : posix . toNamespacedPath ) ;
1683+ export const sep = ( process . platform === 'win32' ? win32 . sep : posix . sep ) ;
1684+ export const delimiter = ( process . platform === 'win32' ? win32 . delimiter : posix . delimiter ) ;
0 commit comments