vgsantoniazzi / js-hcl-parser

js-hcl-parser — A Go port version of HCL <> JSON parser for Javascript.
23 stars 1 forks source link

Parsing for Terraform variables #1

Closed rzodkiewiczmr closed 4 years ago

rzodkiewiczmr commented 4 years ago

I'm trying to parse HCL file with list of variables, parsing fails.

const input = variable my_variable { description = "Some description" type = string }' HCL.parse(input)

(I've changed ` into ' in JS code)

fails with error:

unable to parse JSON: At 4:12: Unknown token: 4:12 IDENT string

Seems like the parser is not ready to parse variables syntax?

vgsantoniazzi commented 4 years ago

@rzodkiewiczmr if you put type = string inside quotes will work:

var HCL = require("js-hcl-parser")

const input = `
variable my_variable {
  description = "Some description"
  type = "string"
}
`

console.log(HCL.parse(input))