[READ-ONLY] Mirror of https://github.com/probablykasper/embler. Turn binaries into applications npmjs.com/package/embler
app builder cli dmg macos node package packager
0

Configure Feed

Select the types of activity you want to include in your feed.

Use temp dir

Kasper (Aug 18, 2020, 5:28 AM +0200) a7a13cb1 10800cda

+43 -15
+43 -15
src/build.js
··· 122 122 for (const [key, value] of Object.entries(options.mac.customInfo)) { 123 123 data[key] = value 124 124 } 125 - plist.writeFileSync(`${paths.ContentsDir}/Info.plist`, data) 125 + plist.writeFileSync(paths.InfoPlist, data) 126 126 127 127 } 128 128 129 129 module.exports.buildMacAppDmg = async function(options, paths) { 130 - 131 - // delete existing .dmg 132 - await clearOutput('file', paths.dmg) 133 130 134 131 const appdmg = require('appdmg') 135 132 await new Promise((resolve, reject) => { ··· 158 155 }) 159 156 } 160 157 161 - module.exports.buildMac = async function(options) { 158 + module.exports.buildMac = async function(options, distDir) { 162 159 const formats = options.mac.formats 163 160 164 161 const paths = {} 165 - paths.distDir = options.outputDir 166 - paths.app = path.join(paths.distDir, `${options.realName}.app`) 167 - paths.dmg = path.join(paths.distDir, `${options.realName}.dmg`) 168 - paths.ContentsDir = path.join(paths.app, 'Contents') 169 - paths.ResourcesDir = path.join(paths.app, 'Contents/Resources') 170 - paths.MacOSDir = path.join(paths.app, 'Contents/MacOS') 171 - paths.icon = path.join(paths.ResourcesDir, 'app.icns') 172 - 162 + paths.distDir = distDir 163 + 164 + paths.app = paths.distDir+`/${options.realName}.app` 165 + paths.appOutput = options.outputDir+`/${options.realName}.app` 166 + paths.dmg = paths.distDir+`/${options.realName}.dmg` 167 + paths.dmgOutput = options.outputDir+`/${options.realName}.dmg` 168 + 169 + paths.ContentsDir = paths.app+'/Contents' 170 + paths.InfoPlist = paths.app+'/Contents/Info.plist' 171 + paths.ResourcesDir = paths.app+'/Contents/Resources' 172 + paths.MacOSDir = paths.app+'/Contents/MacOS' 173 + paths.icon = paths.ResourcesDir+'/app.icns' 174 + 173 175 log.info('Building macOS app') 174 176 await module.exports.buildMacApp(options, paths) 175 177 176 178 if (formats.includes('app/dmg') || formats.includes('dmg')) { 177 179 log.info('Building macOS app/dmg') 178 180 await module.exports.buildMacAppDmg(options, paths) 181 + await clearOutput('file', paths.dmgOutput) 182 + await fs.rename(paths.dmg, paths.dmgOutput) 179 183 } 184 + 185 + if (formats.includes('app')) { 186 + await clearOutput('dir', paths.appOutput) 187 + await fs.rename(paths.app, paths.appOutput) 188 + } 189 + 180 190 } 181 191 182 - module.exports.build = async function(options) { 183 - if (options.mac) await module.exports.buildMac(options) 192 + module.exports.build = async function(options) { 193 + const tempDir = path.join(options.outputDir, '.pakager-temp') 194 + await clearOutput('dir', tempDir) 195 + 196 + let startedCleaning 197 + async function cleanTempDir(dontExit) { 198 + if (startedCleaning) return 199 + startedCleaning = true 200 + await clearOutput('dir', tempDir) 201 + if (dontExit === 'nodontexit') process.exit() 202 + } 203 + process.on('exit', cleanTempDir) 204 + process.on('SIGINT', cleanTempDir) 205 + process.on('SIGTERM', cleanTempDir) 206 + process.on('SIGHUP', cleanTempDir) 207 + process.on('SIGBREAK', cleanTempDir) 208 + 209 + await fs.mkdir(tempDir, { recursive: true }) 210 + if (options.mac) await module.exports.buildMac(options, tempDir) 211 + await cleanTempDir('nodontexit') 184 212 }