Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to ignore if file doesnt exist #13

Open
DusanMilko opened this issue Mar 20, 2015 · 1 comment
Open

A way to ignore if file doesnt exist #13

DusanMilko opened this issue Mar 20, 2015 · 1 comment

Comments

@DusanMilko
Copy link

I want to try to load the json file and if it doesnt exists just ignore and keep going.

Advice?

@colynb
Copy link
Owner

colynb commented Mar 29, 2015

Try this...

gulp.task('json-test', function() {
  return gulp.src('./examples/test1.html')
    .pipe(data(function(file) {
      var path = './examples/' + path.basename(file.path) + '.json';
      return (fs.existsSync(path)) ? require(path) : {};
    }))
    .pipe(swig())
    .pipe(gulp.dest('build'));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants