@@ -21,7 +21,9 @@ commander.version(process.env.VERSION || "development")
2121 . description ( "Run VS Code on a remote server." )
2222 . option ( "--cert <value>" )
2323 . 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." )
2527 . option ( "-h, --host <value>" , "Customize the hostname." , "0.0.0.0" )
2628 . option ( "-o, --open" , "Open in the browser on startup." , false )
2729 . option ( "-p, --port <number>" , "Port to bind on." , 8443 )
@@ -51,6 +53,9 @@ const bold = (text: string | number): string | number => {
5153 readonly host : string ;
5254 readonly port : number ;
5355
56+ readonly userDataDir ?: string ;
57+ readonly extensionsDir ?: string ;
58+
5459 readonly dataDir ?: string ;
5560 readonly password ?: string ;
5661 readonly open ?: boolean ;
@@ -67,7 +72,8 @@ const bold = (text: string | number): string | number => {
6772 const noAuthValue = ( commander as any ) . auth ;
6873 options . noAuth = ! noAuthValue ;
6974
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" ) ;
7177 const workingDir = path . resolve ( args [ 0 ] || process . cwd ( ) ) ;
7278
7379 if ( ! fs . existsSync ( dataDir ) ) {
@@ -81,6 +87,7 @@ const bold = (text: string | number): string | number => {
8187 await Promise . all ( [
8288 fse . mkdirp ( cacheHome ) ,
8389 fse . mkdirp ( dataDir ) ,
90+ fse . mkdirp ( extensionsDir ) ,
8491 fse . mkdirp ( workingDir ) ,
8592 ] ) ;
8693
@@ -144,10 +151,15 @@ const bold = (text: string | number): string | number => {
144151 }
145152
146153 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+
147159 // TODO: fill in appropriate doc url
148160 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 ) ;
151163 const sendSharedProcessReady = ( socket : WebSocket ) : void => {
152164 const active = new SharedProcessActive ( ) ;
153165 active . setSocketPath ( sharedProcess . socketPath ) ;
@@ -196,6 +208,7 @@ const bold = (text: string | number): string | number => {
196208 }
197209 } ,
198210 serverOptions : {
211+ extensionsDirectory : extensionsDir ,
199212 builtInExtensionsDirectory : builtInExtensionsDir ,
200213 dataDirectory : dataDir ,
201214 workingDirectory : workingDir ,
0 commit comments