Mailspring/build/tasks/generate-license-task.coffee
Evan Morikawa fc4b3b56d7 refactor(utils): switch to regular underscore
Summary:
Fixes: T1334

remove final InboxApp references

move out all underscore-plus methods

Mass find and replace of underscore-plus

sed -i '' -- 's/underscore-plus/underscore/g' **/*.coffee
sed -i '' -- 's/underscore-plus/underscore/g' **/*.cjsx

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1534
2015-05-19 16:06:59 -07:00

47 lines
1.4 KiB
CoffeeScript

fs = require 'fs'
path = require 'path'
module.exports = (grunt) ->
grunt.registerTask 'generate-license', 'Generate the license, including the licenses of all dependencies', (mode) ->
legalEagle = require 'legal-eagle'
done = @async()
options =
path: process.cwd()
overrides: require './license-overrides'
legalEagle options, (err, dependencyLicenses) ->
if err?
console.error(err)
exit 1
licenseText = getLicenseText(dependencyLicenses)
if mode is 'save'
targetPath = path.join(grunt.config.get('atom.appDir'), 'LICENSE.md')
fs.writeFileSync(targetPath, licenseText)
else
console.log licenseText
done()
getLicenseText = (dependencyLicenses) ->
{keys} = require 'underscore'
text = """
#{fs.readFileSync('LICENSE.md', 'utf8')}
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} = dependencyLicenses[name]
text += "-------------------------------------------------------------------------\n\n"
text += "Package: #{name}\n"
text += "License: #{license}\n"
text += "License Source: #{source}\n" if source?
if sourceText?
text += "Source Text:\n\n"
text += sourceText
text += '\n'
text