Giter Club home page Giter Club logo

gulp-data's People

Contributors

browncolyn avatar clbrown avatar colynb avatar izaakschroeder avatar kflorence avatar noraj avatar phillipgreenii avatar sh-vi avatar shinnn avatar solarmosaic-kflorence avatar stephenlacy avatar thedancingcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gulp-data's Issues

Doesn't work with multiple gulp sources

Found an issue where if you try to run multiple files through the pipeline only a single file makes it through. This is because of an unneccessary variable assignment

auto-reload browser when changing data.json

I've looked at similar problems here and here, but still couldn't solve the problem.

Help please to create a task for Gulp.
Need to when changing 'data.json ' worked auto-reload. (using browserSync)

This is my gulpfile

mygulp

I tried adding this line to my 'watch' task:

gulp.watch('src/data.json', gulp.series('nunjucks'));

But this did not solve the problem. To see the changes, you need to shut down 'Gulp' and start again.

multiple output streams need a new file or data is overwritten

Data is overwritten on the file object, which breaks piping from a single stream multiple times. For example, the below task will always have file.data.foo = "baz" Perhaps the file object should be cloned before the data is extended? Or perhaps an option for that behaviour would be useful? Is there a better way to get that effect I'm missing?

gulp.task("test", function() {
    var a = gulp.src(files)
        .pipe(data(function(file) { return { foo: "bar" }; }));

    var b = a
        .pipe(rename("something.else"))
        .pipe(data(function(file) { return { foo: "baz" }; }));

    return merge(a, b)
        .pipe(gulp.dest("./dist/"));
}

Using multiple json files with extended arrays

The current behaviour is that, when you using multiple json files and you create the same array in different json file. The array get's overwritten, the better behaviour would be to extend it / merge it with existing array.

Example: I have global json file, where I have array and I need to extend it on different page.

path issue

Shouldn't it be path.basename(file.path,'.html') instead of path.basename(file.path)?

Error: Error: Cannot find module './app/templates/index.html.json'

Please provide a cache option

Hello! I'm using this plugin to add some data for gulp-swig.

This plugin has a cache for readed files?
Why when I changed data files, same content in return like first time?

gulp-data not throwing errors (with gulp-jade)

Hi,

I'm having issues where the gulp-data plugin is not giving me compilation errors.

Please see my compile-jade task below.

'use strict';

var path = require('path');

module.exports = function(gulp, plugins, config, browserSync) {
    return function() {
        var jadeParams = {
            pretty: true,
            compileDebug: true
        };
        gulp.src(config.templatesSource, { base: './src' })
            .pipe(plugins.data(function(file) {
                try {
                    return require( path.resolve( '.', config.dataFile ) );
                } catch (e) {
                    return plugins.util.log(plugins.util.colors.magenta('jade error'), e);
                }
            }))
            .pipe(plugins.jade(jadeParams))
            .pipe(gulp.dest(config.outputDistDir))
            .pipe(browserSync.stream());
    };
};

If I run gulp compile-jade I simply get the "task finished" in the terminal. Running jade <template> manually in the terminal gives me the syntax error that I want.

If I remove the plugins.data pipe part, then running gulp compile-jade again will give me the correct syntax errors. So I'm wondering, what is wrong with the require above? Why is it making jade not give me errors?

Everything will work fine without any syntax error (including the data being passed).

Can you spot any errors with this approach?

How can i append the data to an existing JSON file?

Hi, how can i append the data i get from front-matter to an existing json file? Here's what i have:

`gulp.task('meta', function(){
return gulp.src(path.posts)
.pipe(plumber({
handleError: onError
}))
.pipe(frontMatter({ property: 'meta'}))
//.pipe(data(function(file){
// file.meta.path = file.path
// }))
.pipe(pluck('meta', 'meta.json'))
.pipe(data(function(file){
file.contents = new Buffer(JSON.stringify({'articles': file.meta}, null, ' '));
//var obj = JSON.parse(require './config.json');
//obj.articles = file.contents;

}))
.pipe(gulp.dest('dev/articles/'))

});`

At the moment it outputs to a meta.json file, i'd like for it to append the data to an existing config.json under an "artilcles" key.

Thanks,
Tiago

Replace deprecated dependency gulp-util

gulp-util has been recently deprecated. Continuing to use this dependency may prevent the use of your library with the latest release of Gulp 4 so it is important to replace gulp-util.

The README.md lists alternatives for all the components so a simple replacement should be enough.

Your package is one of the most popular packages still relying on gulp-util, it would be good to publish a fixed version to npm as soon as possible.

See:

Empty HTML

My problem is that my views:build task includes the templates before the data gets injected, resulting in a blank html page. What am i doing wrong?

This is my code:

gulp.task('views:build', ['views:templates'] , () => {
  return gulp.src(config.views.src + '*.twig')
      .pipe($.data(function() {
        return JSON.parse(fs.readFileSync('src/data/timber.json'))
      })) // load data from base json file
      .pipe($.twig())
      .pipe(gulp.dest(config.views.tmp))
      .pipe(reload({stream: true}));
});

gulp.task('views:templates', () => {
  return gulp.src(config.views.src + 'templates/*.twig')
      .pipe($.data(function(file) {
        return JSON.parse(fs.readFileSync('src/data/' + path.basename(file.path).replace('.twig', '') 
+ '.json'));
      }))
      .pipe($.twig())
      .pipe(gulp.dest(config.views.tmp))
});

JSON not updating.

I'm having an issue with a task I'm watching. I'm compiling handlebars templates, partials, and dynamically loading a JSON file for each hbs template.

The task compiles 100% fine manually kicking it off but when I use watch, the JSON data is not updated. I am watching all templates, partials and JSON files. The task is firing successfully when any of the files are modified. It just doesn't pick up any changes to the JSON files.

Here's what I'm doing:

return gulp.src(template_src)
    .pipe(data(function(file) {
        var dir = (file.path.split('/templates/')[1].split('/').length > 1) ? file.path.split('/templates/')[1].split('/')[0] : '';
        return require(data_src + '/' + dir + '/' + path.basename(file.path, '.hbs') + '.json');
    }))
    .pipe(handlebars(null, hbs_options))
    .pipe(rename(function(path) {
        path.extname = '.html';
    }))
    .pipe(minify_html(min_options))
    .pipe(gulp.dest(dest));

Reload data with browsersync when modify json

Hi,

When I start the server, the json loads as it should be, but with the gulp and browsersync already running, if I make a modification on my json file, it didn't reflect the changes on the browser, only if I restart browsersync.

Do you know how can I achieve the instant reload of data from json, with browsersync?
I think it's some cache from the 'require' function of nodejs.

Here's a piece of my Gulpfile:

// Jade templates compilation
gulp.task('templates', function() {
    return gulp.src('assets/views/*.jade')
        .pipe($.data(function(file) {
            return require('./assets/views/' + path.basename(file.path).split('.', 1)[0] + '.json'); 
        }))
        .pipe($.jade({
          pretty: true
        }))
        .pipe(gulp.dest('dist/'))
        .pipe(reload({stream: true}));
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.