forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
33 lines (28 loc) · 859 Bytes
/
run.js
File metadata and controls
33 lines (28 loc) · 859 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
29
30
31
32
33
'use strict'
const path = require('path')
const cp = require('child_process')
const fs = require('fs')
const distInfo = require('./dist-info')
const distPath = distInfo.getDistPath()
const productName = distInfo.getProductName()
let binaryPath = ''
if (process.platform === 'darwin') {
binaryPath = path.join(distPath, `${productName}.app`, 'Contents', 'MacOS', `${productName}`)
} else if (process.platform === 'win32') {
binaryPath = path.join(distPath, `${productName}.exe`)
} else {
console.error(`I dunno how to run on ${process.arch} :(`)
process.exit(1)
}
module.exports = function () {
try {
const stats = fs.statSync(binaryPath)
if (!stats.isFile()) {
return null
}
} catch (e) {
return null
}
const env = Object.assign({}, process.env, {NODE_ENV: 'development'})
return cp.spawn(binaryPath, [], {env})
}