Skip to content

Commit

Permalink
Allow config to override app metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki committed Nov 13, 2014
1 parent e7d8e06 commit 0f9992c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ module.exports = (grunt) ->

done = @async()

{appDirectory, authors, description, iconUrl, loadingGif, outputDirectory, owners} = grunt.config(@name)
outputDirectory ?= path.resolve('.')
loadingGif ?= path.resolve(__dirname, '..', 'resources', 'install-spinner.gif')
config = grunt.config(@name)

metadata = grunt.file.readJSON(path.join(appDirectory, 'resources', 'app', 'package.json'))
appDirectory = path.resolve(config.appDirectory)

metadata.authors ?= authors ? metadata.author?.name ? metadata.author ? ''
metadata.description ?= description ? ''
outputDirectory = config.outputDirectory ? '.'
outputDirectory = path.resolve(outputDirectory)

loadingGif = config.loadingGif ? path.resolve(__dirname, '..', 'resources', 'install-spinner.gif')
loadingGif = path.resolve(loadingGif)

appMetadata = grunt.file.readJSON(path.join(appDirectory, 'resources', 'app', 'package.json'))
metadata = _.extend({}, appMetadata, config)

metadata.authors ?= metadata.author?.name ? metadata.author ? ''
metadata.description ?= ''
metadata.exe ?= "#{metadata.name}.exe"
metadata.iconUrl ?= iconUrl ? 'https://raw.githubusercontent.com/atom/atom-shell/master/atom/browser/resources/win/atom.ico'
metadata.owners ?= owners ? metadata.authors
metadata.iconUrl ?= 'https://raw.githubusercontent.com/atom/atom-shell/master/atom/browser/resources/win/atom.ico'
metadata.owners ?= metadata.authors

template = _.template(grunt.file.read(path.resolve(__dirname, '..', 'template.nuspec')))
nuspecContent = template(metadata)
Expand Down

0 comments on commit 0f9992c

Please sign in to comment.