Alright so I have YAML files, that are being transformed into JSON files. That part is done. But I need to read the JSON files into their appropriate json objects to send to a Firebase Database. Current gulpfile:
var gulp = require('gulp');
var yaml = require('gulp-yaml');
var replace = require('gulp-replace');
var firebase = require('firebase');
var paths = {
yaml: ['~/devel/Git/core-rules/feats/*.yml',
'~/devel/Git/core-rules/banes/*.yml',
'~/devel/Git/core-rules/boons/*.yml']
};
require('firebase/auth');
require('firebase/database');
// compile rules from yaml to json and output to
gulp.task('yaml', function(){
gulp.src(paths.yaml)
.pipe(yaml({
space: 2
}))
// replaces newlines from YAML "foo : |" linebreaks
.pipe(replace('\\n', '<br />'))
.pipe(gulp.dest('./app'))
});
It has no dependancy problems, but only reads 1 file (there should be 3) I need to get the JSON that was written (once there's a JSON file for each YAML file) into a JSON object. Once that's done, it'll be set/pushed to the firebase database.
Thanks to: @hapticdata and @Jon Surrell
var fs = require('fs');
var json = JSON.parse(fs.readFileSync('./data.json'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.