diff --git a/lib/metadata_json_lint.rb b/lib/metadata_json_lint.rb index 9e72dcb..7b6c586 100644 --- a/lib/metadata_json_lint.rb +++ b/lib/metadata_json_lint.rb @@ -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 @@ -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 diff --git a/tests/test.sh b/tests/test.sh index bf0af07..9d4fb8d 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -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