vscode/src/paths.js

24 lines
983 B
JavaScript
Raw Normal View History

2016-05-04 10:43:55 +02:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var path = require('path');
var os = require('os');
2016-08-17 12:53:51 +02:00
var pkg = require('../package.json');
2016-05-04 10:43:55 +02:00
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');
}
}
2016-08-17 12:53:51 +02:00
function getDefaultUserDataPath(platform) {
2016-08-17 12:53:51 +02:00
return path.join(getAppDataPath(platform), pkg.name);
2016-05-04 10:43:55 +02:00
}
exports.getAppDataPath = getAppDataPath;
2016-08-17 12:53:51 +02:00
exports.getDefaultUserDataPath = getDefaultUserDataPath;