github-desktop/script/package

60 lines
1.7 KiB
Text
Raw Normal View History

2016-05-25 14:37:27 +00:00
#!/usr/bin/env node
'use strict'
const fs = require('fs-extra')
const cp = require('child_process')
const path = require('path')
2016-05-25 14:37:27 +00:00
const distInfo = require('./dist-info')
const distPath = distInfo.getDistPath()
const productName = distInfo.getProductName()
if (process.platform === 'darwin') {
packageOSX()
} else if (process.platform === 'win32') {
packageWindows()
} else {
console.error(`I dunno how to package for ${process.platform} :(`)
process.exit(1)
}
function packageOSX () {
2016-05-25 20:49:06 +00:00
const dest = distInfo.getOSXZipPath()
2016-05-25 14:37:27 +00:00
fs.removeSync(dest)
cp.execSync(`ditto -ck --keepParent ${distPath}/${productName}.app ${dest}`)
console.log(`Zipped to ${dest}`)
}
function packageWindows () {
const electronInstaller = require('electron-winstaller')
2016-05-25 15:10:30 +00:00
const outputDir = path.join(distPath, '..', 'installer')
const setupCertificatePath = path.join(__dirname, 'setup-windows-certificate.ps1')
const cleanupCertificatePath = path.join(__dirname, 'cleanup-windows-certificate.ps1')
if (process.env.APPVEYOR) {
cp.execSync(`powershell ${setupCertificatePath}`)
}
const certificatePath = path.join(__dirname, 'windows-certificate.pfx')
electronInstaller
.createWindowsInstaller({
appDirectory: distPath,
2016-05-25 15:10:30 +00:00
outputDirectory: outputDir,
authors: distInfo.getCompanyName(),
exe: `${productName}.exe`,
signWithParams: `/f ${certificatePath} /p ${process.env.WINDOWS_CERT_PASSWORD} /tr http://timestamp.digicert.com /td sha256`
})
.then(() => {
console.log(`Installers created in ${outputDir}`)
cp.execSync(`powershell ${cleanupCertificatePath}`)
})
.catch(e => {
cp.execSync(`powershell ${cleanupCertificatePath}`)
console.error(`Error packaging: ${e}`)
process.exit(1)
})
2016-05-25 14:37:27 +00:00
}