Skip to content

Commit

Permalink
Add unit tests and report coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalre committed Mar 22, 2022
1 parent 31fd8b2 commit bd862f7
Show file tree
Hide file tree
Showing 9 changed files with 7,904 additions and 1,612 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"env": {
"jest": true,
"browser": true,
"es2021": true
},
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ jobs:
run: npm run lint
- name: test
run: npm run test
- name: coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# homeassistant-js-yaml-schema

[![Coverage Status](https://coveralls.io/repos/github/pascalre/homeassistant-js-yaml-schema/badge.svg?branch=master)](https://coveralls.io/github/pascalre/homeassistant-js-yaml-schema?branch=master)

Schema to allow js-yaml to process YAML formatted Home Assistent templates that use Home Assistent specific [local tags](https://www.home-assistant.io/docs/configuration/splitting_configuration/) while parsing or dumping, for example: `!env_var`, `!include_dir_named`.

See [tags.json](https://github.com/pascalre/homeassistant-js-yaml-schema/blob/master/src/tags.json) for currently supported local tags.

# Usage
```typescript
import * as jsyaml from "js-yaml"
const jsyaml = require('js-yaml');
const fs = require('fs');
import { HOMEASSISTANT_SCHEMA } from "homeassistant-js-yaml-schema"

let body = jsyaml.load(yamlDocument, { schema: HOMEASSISTANT_SCHEMA });
let doc = yaml.load(fs.readFileSync('/path/to/file.yml', 'utf8'));
let body = jsyaml.load(doc, { schema: HOMEASSISTANT_SCHEMA });
console.log(JSON.stringify(body, null, 2));

body = jsyaml.dump(body, { schema: HOMEASSISTANT_SCHEMA });
Expand Down

0 comments on commit bd862f7

Please sign in to comment.