yaml-hook

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i yaml-hook

Weekly Downloads

250

Version

1.0.0

License

Apache-2.0

Unpacked Size

9.37 kB

Total Files

11

Last publish

Collaborators

  • goto-bus-stop