MCPcopy
hub / github.com/microsoft/vscode / configurePortable

Function configurePortable

src/bootstrap-node.ts:133–190  ·  view source on GitHub ↗
(product: Partial<IProductConfiguration>)

Source from the content-addressed store, hash-verified

131 * Helper to enable portable mode.
132 */
133export function configurePortable(product: Partial<IProductConfiguration>): { portableDataPath: string; isPortable: boolean } {
134 const appRoot = path.dirname(import.meta.dirname);
135
136 function getApplicationPath(): string {
137 if (process.env['VSCODE_DEV']) {
138 return appRoot;
139 }
140
141 if (process.platform === 'darwin') {
142 return path.dirname(path.dirname(path.dirname(appRoot)));
143 }
144
145 // appRoot = ..\Microsoft VS Code Insiders\<version>\resources\app
146 if (process.platform === 'win32' && product.win32VersionedUpdate) {
147 return path.dirname(path.dirname(path.dirname(appRoot)));
148 }
149
150 return path.dirname(path.dirname(appRoot));
151 }
152
153 function getPortableDataPath(): string {
154 if (process.env['VSCODE_PORTABLE']) {
155 return process.env['VSCODE_PORTABLE'];
156 }
157
158 if (process.platform === 'win32' || process.platform === 'linux') {
159 return path.join(getApplicationPath(), 'data');
160 }
161
162 const portableDataName = product.portable || `${product.applicationName}-portable-data`;
163 return path.join(path.dirname(getApplicationPath()), portableDataName);
164 }
165
166 const portableDataPath = getPortableDataPath();
167 const isPortable = !('target' in product) && fs.existsSync(portableDataPath);
168 const portableTempPath = path.join(portableDataPath, 'tmp');
169 const isTempPortable = isPortable && fs.existsSync(portableTempPath);
170
171 if (isPortable) {
172 process.env['VSCODE_PORTABLE'] = portableDataPath;
173 } else {
174 delete process.env['VSCODE_PORTABLE'];
175 }
176
177 if (isTempPortable) {
178 if (process.platform === 'win32') {
179 process.env['TMP'] = portableTempPath;
180 process.env['TEMP'] = portableTempPath;
181 } else {
182 process.env['TMPDIR'] = portableTempPath;
183 }
184 }
185
186 return {
187 portableDataPath,
188 isPortable
189 };
190}

Callers 2

main.tsFile · 0.85
cli.tsFile · 0.85

Calls 3

getPortableDataPathFunction · 0.85
dirnameMethod · 0.65
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…