Skip to content

Commit 4589a41

Browse files
committed
(PDOC-224) Handle --emit-json(-stdout) again
1 parent 47e5741 commit 4589a41

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

lib/puppet/face/strings.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def build_generate_options(options = nil, *yard_args)
119119
else
120120
raise RuntimeError, "Invalid format #{options[:format]}. Please select 'json' or 'markdown'."
121121
end
122+
elsif options[:emit_json] || options[:emit_json_stdout]
123+
generate_options[:json] = true
122124
end
123125
end
124126
generate_options

spec/acceptance/emit_json_options.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,20 @@
5252
output = read_file_on(master, tmpfile)
5353
expect(JSON.parse(output)).to eq(expected)
5454
end
55+
56+
it 'should emit JSON to stdout when using --emit-json-stdout' do
57+
test_module_path = get_test_module_path(master, /Module test/)
58+
on master, puppet('strings', 'generate', '--emit-json-stdout', "#{test_module_path}/lib/puppet/parser/functions/function3x.rb") do
59+
output = stdout.chomp
60+
expect(JSON.parse(output)).to eq(expected)
61+
end
62+
end
63+
64+
it 'should write JSON to a file when using --emit-json' do
65+
test_module_path = get_test_module_path(master, /Module test/)
66+
tmpfile = master.tmpfile('json_output.json')
67+
on master, puppet('strings', 'generate', '--emit-json', tmpfile, "#{test_module_path}/lib/puppet/parser/functions/function3x.rb")
68+
output = read_file_on(master, tmpfile)
69+
expect(JSON.parse(output)).to eq(expected)
70+
end
5571
end

0 commit comments

Comments
 (0)