yaml-hook
require() hook to load .yml/.yaml YAML files as JS objects
Last updated 2 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install yaml-hook 
SYNC missed versions from official npm registry.

yaml-hook

require() hook to load .yml/.yaml YAML files as JS objects

Install - Usage - License: Apache-2.0

npm travis standard

Install

npm install yaml-hook

Usage

This hook supports .yml and .yaml files. It uses js-yaml's safeLoad function, so YAML-native things are supported, and JS-specific regex/function types are not supported.

var yamlHook = require('yaml-hook')

// install the hook
var hook = yamlHook()

// require() a yaml file
console.log(require('./somefile.yml'))

// uninstall the hook
hook.revert()

// can no longer require yaml files
// → throws
require('./otherfile.yaml')

To install the hook globally, you can do this at the entry point of your app:

require('yaml-hook/register')

This also works with transpiled ES modules using Babel. Note that it does not work with native ES modules, because yaml-hook uses the CommonJS hooking mechanism.

import 'yaml-hook/register'

License

Apache-2.0

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 7
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |