Esempio n. 1
0
 .pipe(intercept(function(file) {
   var o = JSON.parse(file.contents.toString()),
   b = {};
   if (!o.hasOwnProperty('data')) {
       // wrap json in a top level property 'data'
       b.data = o;
       // assign a unique id to each entry in data
       for (var j in b.data) {
         if (!b.data[j].hasOwnProperty('id')) {
           if (b.data[j].hasOwnProperty('title')) {
             // use title to create hash if exists,
             b.data[j].id = md5(b.data[j].title);
             // otherwise use first prop
           } else {
             b.data[j].id = md5(b.data[j][Object.keys(b.data[j])[0]]);
           }
         }
       }
       if (cliOptions.verbose) {
         util.log(util.colors.magenta('Converting yaml ' + file.path), 'to json as', util.colors.blue(JSON.stringify(b)));
       }
       file.contents = new Buffer(JSON.stringify(b));
     }
     return file;
   }))
Esempio n. 2
0
  through.obj(function(file, enc, done) {
    const res = Handlebars.precompile(file.contents.toString(), {
      strict: false,
      data: false
    });

    file.contents = new Buffer(res);
    done(null, file);
  });
Esempio n. 3
0
 through.obj(function(file, enc, done) {
   var reqs = getTemplateRequirements(file.contents.toString());
   file.contents = new Buffer(reqs + file.contents.toString()); 
   done(null, file);
 });
Esempio n. 4
0
 transform: (filePath, file) => {
   console.log(filePath);
   return file.contents.toString("utf8")
 }