Add check-licenses task and break license-overrides into their own file

This commit is contained in:
Nathan Sobo
2014-02-14 18:54:00 -07:00
parent f468420a29
commit 1bf98f5b8d
3 changed files with 58 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
module.exports = (grunt) ->
grunt.registerTask 'check-licenses', 'Report the licenses of all dependencies', ->
legalEagle = require 'legal-eagle'
{size, keys} = require 'underscore-plus'
done = @async()
options =
path: process.cwd()
omitPermissive: true
overrides: require './license-overrides'
legalEagle options, (err, summary) ->
if err?
console.error(err)
exit 1
if size(summary)
console.error "Found dependencies without permissive licenses:"
for name in keys(summary).sort()
console.error "#{name}"
console.error " License: #{summary[name].license}"
console.error " Repository: #{summary[name].repository}"
exit 1
done()

View File

@@ -1,37 +1,4 @@
module.exports = (grunt) ->
grunt.registerTask 'report-licenses', 'Report the licenses of all dependencies', ->
legalEagle = require 'legal-eagle'
done = @async()
options =
path: process.cwd()
overrides: ManualOverrides
legalEagle options, (err, summary) ->
if err?
console.error(err)
exit 1
console.log getSummaryText(summary)
done()
getSummaryText = (summary) ->
{keys} = require 'underscore-plus'
text = ""
names = keys(summary).sort()
for name in names
{license, source, sourceText} = summary[name]
text += "## #{name}\n\n"
text += "* License: #{license}\n"
text += "* License Source: #{source}\n" if source?
if sourceText?
text += "* Source Text:\n"
for line in sourceText.split('\n')
text += "> #{line}\n"
text += '\n'
text
ManualOverrides =
module.exports =
'underscore@1.4.4':
repository: 'https://github.com/documentcloud/underscore'
license: 'MIT'

View File

@@ -0,0 +1,32 @@
module.exports = (grunt) ->
grunt.registerTask 'report-licenses', 'Report the licenses of all dependencies', ->
legalEagle = require 'legal-eagle'
done = @async()
options =
path: process.cwd()
overrides: require './license-overrides'
legalEagle options, (err, summary) ->
if err?
console.error(err)
exit 1
console.log getSummaryText(summary)
done()
getSummaryText = (summary) ->
{keys} = require 'underscore-plus'
text = ""
names = keys(summary).sort()
for name in names
{license, source, sourceText} = summary[name]
text += "## #{name}\n\n"
text += "* License: #{license}\n"
text += "* License Source: #{source}\n" if source?
if sourceText?
text += "* Source Text:\n"
for line in sourceText.split('\n')
text += "> #{line}\n"
text += '\n'
text