Skip to content

Commit

Permalink
Merge pull request #41 from ghoneycutt/default_metadata_json
Browse files Browse the repository at this point in the history
Do not require that the filename 'metadata.json' be passed.
  • Loading branch information
jyaworski authored Nov 2, 2016
2 parents 461c8cb + 54c1442 commit c7edb6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/metadata_json_lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def options

def run
OptionParser.new do |opts|
opts.banner = 'Usage: metadata-json-lint [options] metadata.json'
opts.banner = 'Usage: metadata-json-lint [options] [metadata.json]'

opts.on('--[no-]strict-dependencies', 'Fail on open-ended module version dependencies') do |v|
options[:strict_dependencies] = v
Expand All @@ -30,9 +30,17 @@ def run
end
end.parse!

abort('Error: Must provide a metadata.json file to parse') if ARGV[0].nil?

MetadataJsonLint.parse(ARGV.first)
mj = if ARGV[0].nil?
if File.readable?('metadata.json')
'metadata.json'
else
abort('Error: metadata.json is not readable or does not exist.')
end
else
ARGV[0]
end

MetadataJsonLint.parse(mj)
end
module_function :run

Expand Down
9 changes: 9 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ test "proprietary" $SUCCESS
# Run without a metadata.json or Rakefile, expect FAILURE
test "no_files" $FAILURE

# Test running without specifying file to parse
cd perfect
bundle exec metadata-json-lint
if [ $? -ne 0 ]; then
fail "Failing Test 'running without specifying metadata.json' (bin)"
else
echo "Successful Test 'running without specifying metadata.json' (bin)"
fi

exit $STATUS

0 comments on commit c7edb6a

Please sign in to comment.