mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
compiler: Add error output to the compiler (#3935)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "optparse"
|
||||
require "open3"
|
||||
|
||||
ROOT = File.expand_path("../../", __FILE__)
|
||||
|
||||
@@ -42,6 +43,17 @@ def log(msg)
|
||||
puts msg if $verbose
|
||||
end
|
||||
|
||||
def command(*args)
|
||||
log "$ #{args.join(' ')}"
|
||||
output, status = Open3.capture2e(*args)
|
||||
if !status.success?
|
||||
output.each_line do |line|
|
||||
log " > #{line}"
|
||||
end
|
||||
warn "Command failed. Aborting."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
usage = """Usage:
|
||||
#{$0} [-v|--verbose] [--replace grammar] url
|
||||
@@ -51,12 +63,12 @@ Examples:
|
||||
"""
|
||||
|
||||
$replace = nil
|
||||
$verbose = false
|
||||
$verbose = true
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = usage
|
||||
opts.on("-v", "--verbose", "Print verbose feedback to STDOUT") do
|
||||
$verbose = true
|
||||
opts.on("-q", "--quiet", "Do not print output unless there's a failure") do
|
||||
$verbose = false
|
||||
end
|
||||
opts.on("-rSUBMODULE", "--replace=SUBMODDULE", "Replace an existing grammar submodule.") do |name|
|
||||
$replace = name
|
||||
@@ -82,23 +94,22 @@ Dir.chdir(ROOT)
|
||||
|
||||
if repo_old
|
||||
log "Deregistering: #{repo_old}"
|
||||
`git submodule deinit #{repo_old}`
|
||||
`git rm -rf #{repo_old}`
|
||||
`script/grammar-compiler -update`
|
||||
command('git', 'submodule', 'deinit', repo_old)
|
||||
command('git', 'rm', '-rf', repo_old)
|
||||
command('script/grammar-compiler', 'update', '-f')
|
||||
end
|
||||
|
||||
log "Registering new submodule: #{repo_new}"
|
||||
`git submodule add -f #{https} #{repo_new}`
|
||||
exit 1 if $?.exitstatus > 0
|
||||
`script/grammar-compiler -add #{repo_new}`
|
||||
command('git', 'submodule', 'add', '-f', https, repo_new)
|
||||
command('script/grammar-compiler', 'add', repo_new)
|
||||
|
||||
log "Confirming license"
|
||||
if repo_old
|
||||
`script/licensed`
|
||||
command('script/licensed')
|
||||
else
|
||||
`script/licensed --module "#{repo_new}"`
|
||||
command('script/licensed', '--module', repo_new)
|
||||
end
|
||||
|
||||
log "Updating grammar documentation in vendor/README.md"
|
||||
`bundle exec rake samples`
|
||||
`script/list-grammars`
|
||||
command('bundle', 'exec', 'rake', 'samples')
|
||||
command('script/list-grammars')
|
||||
|
||||
@@ -9,4 +9,4 @@ mkdir -p grammars
|
||||
exec docker run --rm \
|
||||
-u $(id -u $USER):$(id -g $USER) \
|
||||
-v $PWD:/src/linguist \
|
||||
-w /src/linguist -ti $image "$@"
|
||||
-w /src/linguist $image "$@"
|
||||
|
||||
Reference in New Issue
Block a user