-
Notifications
You must be signed in to change notification settings - Fork 0
aron/gopherjs-hcltojson
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
HCL to JSON
===========
This package uses GopherJS[1] to convert the tmccombs/hcl2json/convert[2]
Golang package into JavaScript and provide it as a CommonJS module. Currently
this uses the 0.3.1 due to breaking changes in the output between 0.3.1 and
0.3.2.
Build
-----
The current repository will need to be checked out into the $GOPATH for
the build to work (this is currently a requirement of GopherJS).
Then run:
% make build
This will generate two files a hcltojson.js and an hcltojson.js.map with
source maps for the minified file.
The output file is ~3.9MB minified and ~700KB gzipped.
Usage
-----
The module exposes a single function `hcltojson()` this takes a string
of HCL2 and returns a JavaScript object:
const { hcltojson } = require('./hcltojson');
const tf = fs.readFileSync('../path/to/terraform.tf', 'utf-8');
const data = hcltojson(tf);
Test
----
A simple assertion that the compiled file works can be run via:
% make test
This will check the parsed result of the example.tf function matches the
content of fixture.json.
TODO
----
1. Support the latest 0.3.2 version of hcl2json.
[1]: https://github.com/gopherjs/gopherjs
[2]: https://github.com/tmccombs/hcl2json/
About
Build the hcl2json Golang lib as a JavaScript CommonJS module
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published