2014-09-04 05:21:26 +04:00
|
|
|
fs = require 'fs'
|
|
|
|
path = require 'path'
|
2014-09-17 02:41:57 +04:00
|
|
|
_ = require 'underscore-plus'
|
2014-09-04 05:21:26 +04:00
|
|
|
|
|
|
|
module.exports = (grunt) ->
|
2014-09-23 04:06:23 +04:00
|
|
|
{spawn, rm} = require('./task-helpers')(grunt)
|
2014-09-04 05:21:26 +04:00
|
|
|
|
|
|
|
grunt.registerTask 'create-installer', 'Create the Windows installer', ->
|
2014-09-23 04:07:00 +04:00
|
|
|
return unless if process.platform is 'win32'
|
2014-09-04 05:21:26 +04:00
|
|
|
|
|
|
|
done = @async()
|
|
|
|
|
|
|
|
buildDir = grunt.config.get('atom.buildDir')
|
|
|
|
atomDir = path.join(buildDir, 'Atom')
|
|
|
|
|
2014-09-17 02:09:30 +04:00
|
|
|
packageInfo = JSON.parse(fs.readFileSync(path.join(atomDir, 'resources', 'app', 'package.json'), {encoding: 'utf8'}))
|
2014-09-23 04:06:23 +04:00
|
|
|
inputTemplate = grunt.file.read(path.join('build', 'windows', 'atom.nuspec.erb'))
|
2014-09-17 02:09:30 +04:00
|
|
|
|
2014-09-17 03:00:57 +04:00
|
|
|
## NB: Build server has some sort of stamp on the version number
|
|
|
|
packageInfo.version = packageInfo.version.replace(/-.*$/, '')
|
|
|
|
|
2014-09-17 02:09:30 +04:00
|
|
|
targetNuspecPath = path.join(buildDir, 'atom.nuspec')
|
2014-09-23 04:06:23 +04:00
|
|
|
grunt.file.write(targetNuspecPath, _.template(inputTemplate, packageInfo))
|
2014-09-17 02:09:30 +04:00
|
|
|
|
2014-09-04 05:21:26 +04:00
|
|
|
cmd = 'build/windows/nuget.exe'
|
2014-09-17 02:09:30 +04:00
|
|
|
args = ['pack', targetNuspecPath, '-BasePath', atomDir, '-OutputDirectory', buildDir]
|
2014-09-04 05:21:26 +04:00
|
|
|
|
|
|
|
spawn {cmd, args}, (error, result, code) ->
|
2014-09-23 04:07:00 +04:00
|
|
|
return done(error) if error?
|
2014-09-04 05:21:26 +04:00
|
|
|
|
|
|
|
pkgs = pkg for pkg in fs.readdirSync(buildDir) when pkg.match /.nupkg$/i
|
|
|
|
|
2014-09-22 21:47:27 +04:00
|
|
|
releasesDir = path.join(buildDir, 'Releases')
|
|
|
|
|
|
|
|
## NB: Gonna clear Releases for now, in the future we need to pull down
|
|
|
|
## the existing version
|
2014-09-23 04:06:23 +04:00
|
|
|
rm(releasesDir)
|
2014-09-04 05:21:26 +04:00
|
|
|
|
2014-09-22 21:47:27 +04:00
|
|
|
cmd = 'build/windows/update.com'
|
|
|
|
args = ['--releasify', path.join(buildDir, pkgs), '-r', releasesDir]
|
2014-09-04 05:21:26 +04:00
|
|
|
spawn {cmd, args}, (error, result, code) -> done(error)
|