pulsar/build/tasks/mkdeb-task.coffee
2014-03-25 15:40:59 +08:00

30 lines
953 B
CoffeeScript

fs = require 'fs'
path = require 'path'
_ = require 'underscore-plus'
fillTemplate = (filePath, data) ->
template = _.template(String(fs.readFileSync(filePath + '.in')))
filled = template(data)
fs.writeFileSync(filePath, filled)
module.exports = (grunt) ->
{spawn} = require('./task-helpers')(grunt)
grunt.registerTask 'mkdeb', 'Create debian package', ->
done = @async()
{name, version, description} = grunt.file.readJSON('package.json')
section = 'devel'
arch = 'amd64'
maintainer = 'GitHub <support@github.com>'
data = {name, version, description, section, arch, maintainer}
control = path.join('resources', 'linux', 'debian', 'control')
fillTemplate(control, data)
desktop = path.join('resources', 'linux', 'Atom.desktop')
fillTemplate(desktop, data)
cmd = path.join('script', 'mkdeb')
args = [version, control, desktop, grunt.config.get('atom.buildDir')]
spawn({cmd, args}, done)