提交 e6343028 编写于 作者: J Joao Moreno

extract userData path computation

上级 e9f9aad3
{
"name": "Code",
"name": "Code - OSS",
"version": "1.1.0",
"electronVersion": "0.37.6",
"author": {
......
......@@ -9,6 +9,8 @@ global.vscodeStart = Date.now();
var app = require('electron').app;
var fs = require('fs');
var path = require('path');
var paths = require('./paths');
var pkg = require('../package.json');
function stripComments(content) {
var regexp = /("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
......@@ -107,19 +109,9 @@ try {
console.error(err);
}
// Set path according to being built or not
if (process.env['VSCODE_DEV']) {
var appData = app.getPath('appData');
app.setPath('userData', path.join(appData, 'Code-Development'));
}
// Use custom user data dir if specified, required to run as root on Linux
var args = process.argv;
args.forEach(function (arg) {
if (arg.indexOf('--user-data-dir=') === 0) {
app.setPath('userData', arg.split('=')[1]);
}
});
// Set userData path before app 'ready' event
var userData = paths.getUserDataPath(process.platform, pkg.name, process.argv);
app.setPath('userData', userData);
// Mac: when someone drops a file to the not-yet running VSCode, the open-file event fires even before
// the app-ready event. We listen very early for open-file and remember this upon startup as path to open.
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var minimist = require('minimist');
var path = require('path');
var os = require('os');
function getAppDataPath(platform) {
switch (platform) {
case 'win32': return process.env['APPDATA'];
case 'darwin': return path.join(os.homedir(), 'Library', 'Application Support');
case 'linux': return process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config');
default: throw new Error('Platform not supported');
}
}
function getUserDataPath(platform, appName, args) {
var argv = minimist(args, { string: ['user-data-dir'] });
var userDataDir = argv['user-data-dir'];
var appData = getAppDataPath(platform);
if (userDataDir) {
return userDataDir;
}
return path.join(appData, appName);
}
exports.getAppDataPath = getAppDataPath;
exports.getUserDataPath = getUserDataPath;
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import uri from 'vs/base/common/uri';
interface IPaths {
getAppDataPath(platform: string): string;
getUserDataPath(platform: string, appName: string, args: string[]): string;
}
const pathsPath = uri.parse(require.toUrl('paths')).fsPath;
const paths = require.__$__nodeRequire<IPaths>(pathsPath);
export const getAppDataPath = paths.getAppDataPath;
export const getUserDataPath = paths.getUserDataPath;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册