Mailspring/build/tasks/mkdmg-task.coffee
Evan Morikawa e8f002ac5d refactor(cruft): remove old Atom docs and other cruft
Summary:
Getting rid of things that I'm pretty sure we don't need. Lmk if you see
anything to the otherwise.

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1799
2015-07-24 14:27:21 -07:00

59 lines
1.9 KiB
CoffeeScript

fs = require 'fs'
path = require 'path'
_ = require 'underscore'
Promise = require("bluebird")
module.exports = (grunt) ->
{spawn, rm} = require('./task-helpers')(grunt)
appName = -> grunt.config.get('atom.appName')
dmgName = -> "#{appName().split('.')[0]}.dmg"
buildDir = -> grunt.config.get('atom.buildDir')
dmgPath = -> path.join(buildDir(), dmgName())
appDir = -> path.join(buildDir(), grunt.config.get('atom.appName'))
getDmgExecutable = ->
new Promise (resolve, reject) ->
dmgMakerRepo = "yoursway-create-dmg"
dmgExecutable = path.join(dmgMakerRepo, "create-dmg")
if fs.existsSync(dmgExecutable) then resolve(dmgExecutable)
else
console.log("---> Downloading yoursway-create-dmg")
spawn
cmd: "git"
args: ["clone", "https://github.com/andreyvit/#{dmgMakerRepo}"]
, (error, results, exitCode) ->
if exitCode is 0 then resolve(dmgExecutable) else reject(error)
removeOldDmg = (dmgExecutable) ->
if fs.existsSync(dmgPath()) then rm dmgPath()
executeDmgMaker = (dmgExecutable) ->
new Promise (resolve, reject) ->
console.log("---> Bulding Nylas DMG")
spawn
cmd: dmgExecutable
args: [
"--volname", "Nylas Installer",
"--volicon", path.join("build", "resources", "nylas.png"),
"--window-pos", "200", "120",
"--window-size", "800", "400",
"--icon-size", "100",
"--icon", appName(), "200", "190",
"--hide-extension", appName(),
"--app-drop-link", "600", "185",
dmgPath()
appDir(),
]
, (error, results, exitCode) ->
if exitCode is 0 then resolve() else reject(error)
grunt.registerTask 'mkdmg', 'Create Mac DMG', ->
done = @async()
removeOldDmg()
getDmgExecutable()
.then(executeDmgMaker)
.then(done)
.catch (error) ->
console.error(error)
done()