-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigUtils.js
More file actions
28 lines (25 loc) · 876 Bytes
/
configUtils.js
File metadata and controls
28 lines (25 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const os = require('os');
const path = require('path');
const { exec } = require('child_process');
function getLocalConfig() {
return new Promise((resolve, reject) => {
const platform = os.platform();
const defaultPaths = {
linux: path.join(os.homedir(), '.config', 'kicad'),
darwin: path.join(os.homedir(), 'Library', 'Preferences', 'kicad'),
win32: path.join(os.homedir(), 'AppData', 'Roaming', 'kicad'),
};
if (platform in defaultPaths) {
resolve({ kicadConfigPath: defaultPaths[platform] });
} else {
exec('kicad --version', (error, stdout, stderr) => {
if (error) {
reject(new Error('Could not determine KiCad config path'));
} else {
resolve({ kicadConfigPath: path.join(os.homedir(), '.config', 'kicad') });
}
});
}
});
}
module.exports = { getLocalConfig };