Skip to content

Commit 42d74a1

Browse files
fix: Ignore strings before json (#73)
Co-authored-by: Oliver Borchert <[email protected]>
1 parent c155d5f commit 42d74a1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

dist/index.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/render.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ export async function renderPlan({
159159
}
160160
const structuredPlanfile = await exec
161161
.getExecOutput(terraformCommand, ['show', '-json', planfile], options)
162-
.then((output) => JSON.parse(output.stdout))
162+
.then((output) => {
163+
const jsonStart = output.stdout.indexOf('{')
164+
if (jsonStart === -1) throw new Error('No JSON found in planfile output')
165+
const jsonText = output.stdout.slice(jsonStart)
166+
return JSON.parse(jsonText)
167+
})
163168
.then((json) => parsePlanfileJSON(json))
164169
const humanReadablePlanfile = await exec
165170
.getExecOutput(terraformCommand, ['show', '-no-color', planfile], options)

0 commit comments

Comments
 (0)