Add getPath helper
This commit is contained in:
parent
d2df641b0d
commit
d5bb1d87cc
1 changed files with 15 additions and 8 deletions
|
@ -22,16 +22,23 @@ function onerror (err) {
|
|||
throw err
|
||||
}
|
||||
|
||||
var paths = {
|
||||
darwin: 'dist/Electron.app/Contents/MacOS/Electron',
|
||||
freebsd: 'dist/electron',
|
||||
linux: 'dist/electron',
|
||||
win32: 'dist/electron.exe'
|
||||
function getPath (platform) {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'dist/Electron.app/Contents/MacOS/Electron'
|
||||
case 'freebsd':
|
||||
case 'linux':
|
||||
return 'dist/electron'
|
||||
case 'win32':
|
||||
return 'dist/electron.exe'
|
||||
default:
|
||||
throw new Error('Electron builds are not available on platform: ' + platform)
|
||||
}
|
||||
}
|
||||
|
||||
if (!paths[platform]) throw new Error('Electron builds are not available on platform: ' + platform)
|
||||
var platformPath = getPath(platform)
|
||||
|
||||
if (installedVersion === version && fs.existsSync(path.join(__dirname, paths[platform]))) {
|
||||
if (installedVersion === version && fs.existsSync(path.join(__dirname, platformPath))) {
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
@ -49,7 +56,7 @@ function extractFile (err, zipPath) {
|
|||
if (err) return onerror(err)
|
||||
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
|
||||
if (err) return onerror(err)
|
||||
fs.writeFile(path.join(__dirname, 'path.txt'), paths[platform], function (err) {
|
||||
fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) {
|
||||
if (err) return onerror(err)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue