A better HCL parser for Javascript applications
This parser is transpiled from hashicorp/hcl using GopherJS.
npm install hcl-parser
import {parse} from "hcl-parser"
const input = `
allow {
user = "admin"
}
deny {
user = "anonymous"
}
`
const [data, err] = parse(input);
if(err == null){
// data is the JSON object you want
} else {
// handle error
}
In case you may want to reproduce this library
The associated code can be found here anhldbk/hcl-parser
To build the parser:
# Install GopherJS first
go get -u github.com/gopherjs/gopherjs
# Build JS package
gopherjs build github.com/anhldbk/hcl-parser -o lib/parser.js -m
npm test