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
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = {
|
function getPath (platform) {
|
||||||
darwin: 'dist/Electron.app/Contents/MacOS/Electron',
|
switch (platform) {
|
||||||
freebsd: 'dist/electron',
|
case 'darwin':
|
||||||
linux: 'dist/electron',
|
return 'dist/Electron.app/Contents/MacOS/Electron'
|
||||||
win32: 'dist/electron.exe'
|
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)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +56,7 @@ function extractFile (err, zipPath) {
|
||||||
if (err) return onerror(err)
|
if (err) return onerror(err)
|
||||||
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
|
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
|
||||||
if (err) return onerror(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)
|
if (err) return onerror(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue