@@ -27,20 +27,25 @@ function getApplicationPath() {
2727 }
2828}
2929
30- function getPortableDataPath ( ) {
31- return path . join ( path . dirname ( getApplicationPath ( ) ) , product . portable ) ;
30+ const portableDataName = product . portable || `${ product . applicationName } -portable-data` ;
31+ const portableDataPath = process . env [ 'VSCODE_PORTABLE' ] || path . join ( path . dirname ( getApplicationPath ( ) ) , portableDataName ) ;
32+ const isPortable = fs . existsSync ( portableDataPath ) ;
33+ const portableTempPath = path . join ( portableDataPath , 'tmp' ) ;
34+ const isTempPortable = isPortable && fs . existsSync ( portableTempPath ) ;
35+
36+ if ( isPortable ) {
37+ process . env [ 'VSCODE_PORTABLE' ] = portableDataPath ;
38+ } else {
39+ delete process . env [ 'VSCODE_PORTABLE' ] ;
3240}
3341
34- if ( product . portable && product . portableTemp ) {
35- const portablePath = getPortableDataPath ( ) ;
36- try { fs . mkdirSync ( portablePath ) ; } catch ( err ) { if ( err . code !== 'EEXIST' ) { throw err ; } }
37-
38- const tmpdir = path . join ( portablePath , 'tmp' ) ;
39- try { fs . mkdirSync ( tmpdir ) ; } catch ( err ) { if ( err . code !== 'EEXIST' ) { throw err ; } }
40-
41- process . env [ process . platform === 'win32' ? 'TEMP' : 'TMPDIR' ] = tmpdir ;
42+ if ( isTempPortable ) {
43+ process . env [ process . platform === 'win32' ? 'TEMP' : 'TMPDIR' ] = portableTempPath ;
4244}
4345
46+ console . log ( 'portableDataPath' , portableDataPath ) ;
47+ console . log ( 'isPortable' , isPortable ) ;
48+
4449//#region Add support for using node_modules.asar
4550( function ( ) {
4651 const path = require ( 'path' ) ;
@@ -377,8 +382,8 @@ function getNodeCachedDataDir() {
377382//#endregion
378383
379384function getUserDataPath ( ) {
380- if ( product . portable ) {
381- return path . join ( getPortableDataPath ( ) , 'user-data' ) ;
385+ if ( isPortable ) {
386+ return path . join ( portableDataPath , 'user-data' ) ;
382387 }
383388
384389 return path . resolve ( args [ 'user-data-dir' ] || paths . getDefaultUserDataPath ( process . platform ) ) ;
0 commit comments