refactor: use app.commandLine.getSwitchValue() for parsing user-data-dir (#18764)

This commit is contained in:
Milan Burda 2019-06-14 01:03:02 +02:00 committed by Samuel Attard
parent 29decbdd4d
commit da58ac7c20

View file

@ -51,10 +51,8 @@ app._setDefaultAppPaths = (packagePath) => {
app.setAppPath(packagePath)
// Add support for --user-data-dir=
const userDataDirFlag = '--user-data-dir='
const userDataArg = process.argv.find(arg => arg.startsWith(userDataDirFlag))
if (userDataArg) {
const userDataDir = userDataArg.substr(userDataDirFlag.length)
if (app.commandLine.hasSwitch('user-data-dir')) {
const userDataDir = app.commandLine.getSwitchValue('user-data-dir')
if (path.isAbsolute(userDataDir)) app.setPath('userData', userDataDir)
}
}