New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

js2yaml

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js2yaml

Create configurations with the power of Javascript and convert it to YAML.


Version published
Weekly downloads
21
increased by61.54%
Maintainers
0
Weekly downloads
 
Created

js2yaml

This small utility allows you to create configuration files with Javascript and convert them to YAML files on the fly.

How does it work

To get started, you have to provide a configuration file (e.g. js2yaml.config.js). E.g. the following configuration converts Javascript to YAML for Magnolia CMS:

module.exports = [
  {
    watch: "../magnolia/light-modules/**/*.js",
    processor: {
      // Process incoming JSON (optional)
      json: (json) => {
        return json
      },
      // Process resulting YAML (optional)
      yaml: (yaml) => {
        return (
          "# This file has been auto-generated.\n" +
          yaml
            .replace(/"!content-type": /g, "!content-type:")
            .replace(/"!inherit": /g, "!inherit:")
            .replace(/!override:/g, ": !override")
        )
      },
      // Process resulting filename (optional)
      file: (file) => {
        return file
      },
    },
  },
]

Now you can start the file watching process via:

node index.js js2yaml.config.js

FAQs

Package last updated on 12 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts