const os = require('os');
const fs = require('fs');
const path = require('path');
function getAppDataPath(appName) {
const platform = os.platform();
let appDataPath;
switch (platform) {
case 'win32':
appDataPath = path.join(process.env.APPDATA || '', appName);
break;
case 'darwin':
appDataPath = path.join(os.homedir(), 'Library', 'Application Support', appName);
break;
case 'linux':
appDataPath = path.join(os.homedir(), '.config', appName);
break;
default:
appDataPath = path.join(os.homedir(), `.${appName}`);
}
return appDataPath;
}
function getOpenCommand() {
const platform = os.platform();
switch (platform) {
case 'win32':
return 'start';
case 'darwin':
return 'open';
default:
return 'xdg-open';
}
}
const appName = 'myapp';
const appDataPath = getAppDataPath(appName);
const openCommand = getOpenCommand();