yaml-hook
require() hook to load .yml/.yaml YAML files as JS objects
Install - Usage - License: Apache-2.0
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 = // install the hookvar hook = // require() a yaml fileconsole // uninstall the hookhook // can no longer require yaml files// → throws
To install the hook globally, you can do this at the entry point of your app:
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.