mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
42 lines
1.5 KiB
CoffeeScript
42 lines
1.5 KiB
CoffeeScript
fs = require 'fs'
|
|
path = require 'path'
|
|
_ = require 'underscore-plus'
|
|
|
|
module.exports = (grunt) ->
|
|
{spawn, rm} = require('./task-helpers')(grunt)
|
|
|
|
grunt.registerTask 'create-installer', 'Create the Windows installer', ->
|
|
return unless if process.platform is 'win32'
|
|
|
|
done = @async()
|
|
|
|
buildDir = grunt.config.get('atom.buildDir')
|
|
atomDir = path.join(buildDir, 'Atom')
|
|
|
|
packageInfo = grunt.file.readJSON(path.join(atomDir, 'resources', 'app', 'package.json'))
|
|
inputTemplate = grunt.file.read(path.join('build', 'windows', 'atom.nuspec.erb'))
|
|
|
|
## NB: Build server has some sort of stamp on the version number
|
|
packageInfo.version = packageInfo.version.replace(/-.*$/, '')
|
|
|
|
targetNuspecPath = path.join(buildDir, 'atom.nuspec')
|
|
grunt.file.write(targetNuspecPath, _.template(inputTemplate, packageInfo))
|
|
|
|
cmd = 'build/windows/nuget.exe'
|
|
args = ['pack', targetNuspecPath, '-BasePath', atomDir, '-OutputDirectory', buildDir]
|
|
|
|
spawn {cmd, args}, (error, result, code) ->
|
|
return done(error) if error?
|
|
|
|
pkgs = pkg for pkg in fs.readdirSync(buildDir) when pkg.match /.nupkg$/i
|
|
|
|
releasesDir = path.join(buildDir, 'Releases')
|
|
|
|
## NB: Gonna clear Releases for now, in the future we need to pull down
|
|
## the existing version
|
|
rm(releasesDir)
|
|
|
|
cmd = 'build/windows/update.com'
|
|
args = ['--releasify', path.join(buildDir, pkgs), '-r', releasesDir]
|
|
spawn {cmd, args}, (error, result, code) -> done(error)
|