gulp-jasyacon

1.1.4 • Public • Published

Gulp JasYaCon

Occasionally we find ourselves with a lot of static JSON objects floating around our scripts, causing clutter and ugliness. JasYaCon (JSON YAML Consolidator) is able to convert a YAML file into a JSON object, and then place that object directly into your script wherever specified, allowing for cleaner code and extremely easy replication.

The alternative use of this package is outside of Gulp. Instead, use the "nopipe" argument to retrieve the direct result returned.

Arguments

  • (glob) glob - The glob containing all of the yaml files for processing.
  • (object) yaml - These are passed directly into Yaml to Json. Please refer to that package's documentation.
  • (bool) nopipe - If true, the YAML glob will be converted and directly returned.
  • (bool) noassoc - If true, the returned object will be an indexed array. By default, the returned value is an associative array based on the name of the YAML file.

Sample Use

First we have our yaml file. Let's say the full path is: ./src/yaml/Persons.yaml

---
    name: "John"
    age: 23
 
---
    name: "Sally"
    age: 51

Now we have our javascript in which we want to import these people. Let's say the full path is ./src/js/myScript.js

var ListOfPeople = /* !!jasyacon Persons */;

Finally, we have our gulpfile.js

var jasyacon = require('gulp-jasyacon'),
    gulp = require('gulp');
 
gulp.task("default", function() {
  gulp.src(['./src/js/**/*.js'])
    .pipe(jasyacon({yamlGlob: './src/yaml/**/*.yaml'}))
    .pipe(gulp.dest('./public/'));
});

This will compile, creating a file with the path ./public/myScript.js That file will look like this:

var ListOfPeople = [{"name": "John", "age": 22},{"name": "Sally", "age": 51}];

Plugins

gulp-jasyacon utilizes the following plugins:

Package Sidebar

Install

npm i gulp-jasyacon

Weekly Downloads

10

Version

1.1.4

License

ISC

Last publish

Collaborators

  • wyatt.arent