mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
* Update licensee version This pulls in Licensed 0.10.0 too. * Use a full path to the grammars Licensed now enforces this as it's easier then guessing. * Ensure full path * Use new path for FSProject * Starting to adjust tests * require licensee again * Fix grammar tests * verify -> status * whitelist -> allowed * explicitly set cache_path in configuration default for licensed v1.0 changed from `vendor/licenses` to `.licenses` * load configuration from file location default configuration file location changed from `vendor/licenses/config.yml` to `.licensed.yml` * update gemspec for licensed 1.0.0 * Remove unused license hash
56 lines
1.3 KiB
Ruby
Executable File
56 lines
1.3 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
# TODO: push these changes to licensor gem
|
|
|
|
require "bundler/setup"
|
|
require "licensed/cli"
|
|
require "optparse"
|
|
|
|
module Licensed
|
|
module Source
|
|
class Filesystem
|
|
attr_reader :type
|
|
|
|
def initialize(glob, type: "directory")
|
|
@glob = glob
|
|
@type = type
|
|
end
|
|
|
|
def enabled?
|
|
!Dir.glob(@glob).empty?
|
|
end
|
|
|
|
def dependencies
|
|
Dir.glob(@glob).map do |directory|
|
|
puts "caching #{directory}"
|
|
Licensed::Dependency.new(directory, {
|
|
"type" => type,
|
|
"name" => File.basename(directory)
|
|
})
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
module_path = nil
|
|
OptionParser.new do |opts|
|
|
opts.on("-mPATH", "--module=PATH", "Cache license file for specific grammar") do |p|
|
|
module_path = p
|
|
end
|
|
end.parse!
|
|
|
|
source = Licensed::Source::Filesystem.new(module_path || "#{File.expand_path("../", File.dirname(__FILE__))}/vendor/grammars/*/", type: "grammar")
|
|
config = Licensed::Configuration.load_from(File.expand_path("../vendor/licenses/config.yml", File.dirname(__FILE__)))
|
|
config.sources << source
|
|
|
|
command = if ARGV[0] == "status"
|
|
Licensed::Command::Status.new(config)
|
|
else
|
|
Licensed::Command::Cache.new(config)
|
|
end
|
|
|
|
command.run
|
|
`git checkout -- vendor/licenses/grammar/` if module_path
|
|
exit command.success?
|