Write LICENSE to the appDir during build task

This commit is contained in:
Nathan Sobo 2014-02-21 12:35:05 -07:00
parent 324ae3fe3a
commit 878831bfc7
2 changed files with 21 additions and 8 deletions

View File

@ -74,7 +74,7 @@ module.exports = (grunt) ->
unless /.+\.plist/.test(sourcePath)
grunt.file.copy(sourcePath, path.resolve(appDir, '..', subDirectory, filename))
dependencies = ['compile']
dependencies = ['compile', "generate-license:save"]
dependencies.push('copy-info-plist') if process.platform is 'darwin'
dependencies.push('set-exe-icon') if process.platform is 'win32'
grunt.task.run(dependencies...)

View File

@ -1,6 +1,8 @@
fs = require 'fs'
path = require 'path'
module.exports = (grunt) ->
grunt.registerTask 'generate-license', 'Generate the license, including the licenses of all dependencies', ->
grunt.registerTask 'generate-license', 'Generate the license, including the licenses of all dependencies', (mode) ->
legalEagle = require 'legal-eagle'
done = @async()
@ -8,19 +10,30 @@ module.exports = (grunt) ->
path: process.cwd()
overrides: require './license-overrides'
legalEagle options, (err, summary) ->
legalEagle options, (err, dependencyLicenses) ->
if err?
console.error(err)
exit 1
console.log getSummaryText(summary)
licenseText = getLicenseText(dependencyLicenses)
if mode is 'save'
targetPath = path.join(grunt.config.get('atom.appDir'), 'LICENSE')
fs.writeFileSync(targetPath, licenseText)
else
console.log licenseText
done()
getSummaryText = (summary) ->
getLicenseText = (dependencyLicenses) ->
{keys} = require 'underscore-plus'
text = ""
names = keys(summary).sort()
text = """
Copyright 2014 GitHub, Inc.
This application bundles the following third-party packages in accordance
with the following licenses:\n\n
"""
names = keys(dependencyLicenses).sort()
for name in names
{license, source, sourceText} = summary[name]
{license, source, sourceText} = dependencyLicenses[name]
text += "-------------------------------------------------------------------------\n\n"
text += "Package: #{name}\n"