@@ -21,7 +21,9 @@ commander.version(process.env.VERSION || "development")
21
21
. description ( "Run VS Code on a remote server." )
22
22
. option ( "--cert <value>" )
23
23
. option ( "--cert-key <value>" )
24
- . option ( "-d, --data-dir <value>" , "Customize where user-data is stored." )
24
+ . option ( "-e, --extensions-dir <dir>" , "Set the root path for extensions." )
25
+ . option ( "-d --user-data-dir <dir>" , " Specifies the directory that user data is kept in, useful when running as root." )
26
+ . option ( "--data-dir <value>" , "DEPRECATED: Use '--user-data-dir' instead. Customize where user-data is stored." )
25
27
. option ( "-h, --host <value>" , "Customize the hostname." , "0.0.0.0" )
26
28
. option ( "-o, --open" , "Open in the browser on startup." , false )
27
29
. option ( "-p, --port <number>" , "Port to bind on." , 8443 )
@@ -51,6 +53,9 @@ const bold = (text: string | number): string | number => {
51
53
readonly host : string ;
52
54
readonly port : number ;
53
55
56
+ readonly userDataDir ?: string ;
57
+ readonly extensionsDir ?: string ;
58
+
54
59
readonly dataDir ?: string ;
55
60
readonly password ?: string ;
56
61
readonly open ?: boolean ;
@@ -67,7 +72,8 @@ const bold = (text: string | number): string | number => {
67
72
const noAuthValue = ( commander as any ) . auth ;
68
73
options . noAuth = ! noAuthValue ;
69
74
70
- const dataDir = path . resolve ( options . dataDir || path . join ( dataHome , "code-server" ) ) ;
75
+ const dataDir = path . resolve ( options . userDataDir || options . dataDir || path . join ( dataHome , "code-server" ) ) ;
76
+ const extensionsDir = options . extensionsDir ? path . resolve ( options . extensionsDir ) : path . resolve ( dataDir , "extensions" ) ;
71
77
const workingDir = path . resolve ( args [ 0 ] || process . cwd ( ) ) ;
72
78
73
79
if ( ! fs . existsSync ( dataDir ) ) {
@@ -81,6 +87,7 @@ const bold = (text: string | number): string | number => {
81
87
await Promise . all ( [
82
88
fse . mkdirp ( cacheHome ) ,
83
89
fse . mkdirp ( dataDir ) ,
90
+ fse . mkdirp ( extensionsDir ) ,
84
91
fse . mkdirp ( workingDir ) ,
85
92
] ) ;
86
93
@@ -144,10 +151,15 @@ const bold = (text: string | number): string | number => {
144
151
}
145
152
146
153
logger . info ( `\u001B[1mcode-server ${ process . env . VERSION ? `v${ process . env . VERSION } ` : "development" } ` ) ;
154
+
155
+ if ( options . dataDir ) {
156
+ logger . warn ( '"--data-dir" is deprecated. Use "--user-data-dir" instead.' ) ;
157
+ }
158
+
147
159
// TODO: fill in appropriate doc url
148
160
logger . info ( "Additional documentation: http://github.com/codercom/code-server" ) ;
149
- logger . info ( "Initializing" , field ( "data-dir" , dataDir ) , field ( "working-dir" , workingDir ) , field ( "log-dir" , logDir ) ) ;
150
- const sharedProcess = new SharedProcess ( dataDir , builtInExtensionsDir ) ;
161
+ logger . info ( "Initializing" , field ( "data-dir" , dataDir ) , field ( "extensions-dir" , extensionsDir ) , field ( " working-dir", workingDir ) , field ( "log-dir" , logDir ) ) ;
162
+ const sharedProcess = new SharedProcess ( dataDir , extensionsDir , builtInExtensionsDir ) ;
151
163
const sendSharedProcessReady = ( socket : WebSocket ) : void => {
152
164
const active = new SharedProcessActive ( ) ;
153
165
active . setSocketPath ( sharedProcess . socketPath ) ;
@@ -196,6 +208,7 @@ const bold = (text: string | number): string | number => {
196
208
}
197
209
} ,
198
210
serverOptions : {
211
+ extensionsDirectory : extensionsDir ,
199
212
builtInExtensionsDirectory : builtInExtensionsDir ,
200
213
dataDirectory : dataDir ,
201
214
workingDirectory : workingDir ,
0 commit comments