Skip to content

Instantly share code, notes, and snippets.

@mislav
Created June 25, 2015 00:41
Show Gist options
  • Save mislav/14fa0888dcbce8879efa to your computer and use it in GitHub Desktop.
Save mislav/14fa0888dcbce8879efa to your computer and use it in GitHub Desktop.
Simple tool to do rudimentary dependency license auditing using Licensee library.
#!/bin/bash
# Usage: license-audit [<project-dir>]
#
# Scans gems from the current project's bundle, Bower components and npm
# packages, and prints their license.
#
# Requires:
# - licensee >= 4.5.0
# - ruby with Bundler (for Gemfiles)
set -e
{ [ ! -e Gemfile ] || ruby -rbundler -e 'puts Bundler.load.specs.map(&:gem_dir)'
ls -d node_modules/* bower_components/* 2>/dev/null
} | while read dir; do
[ -d "$dir" ] || continue
echo -n "${dir##*/}: "
licensee "$dir" 2>/dev/null | grep 'License:\|Unknown' | sed 's/License: //'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment