gulp-drafts
Gulp plugin for skipping files marked as drafts.
Last updated 6 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-drafts 
SYNC missed versions from official npm registry.

gulp-drafts NPM version Build Status

Gulp plugin for removing files flagged as drafts. Can also be used as an assemble or verb plugin.

The filtering part of the plugin was inspired by gulp-filter.

Install with npm

npm i gulp-drafts --save

Usage

All of the following examples should work in any combination with one another.

Ignore files using glob patterns

var gulp = require('gulp');
var drafts = require('gulp-drafts');

gulp.task('blog', function () {
  gulp.src('posts/**/*.md')
    // remove files from the pipeline if they match the given
    // filepath or glob patterns:
    .pipe(drafts('**/drafts/*.md'))
    .pipe(gulp.dest('dist'));
});

Ignore files with the draft property

The plugin automatically filters out files with the draft or data.draft property set to true. Files won't have these properties unless you're setting them on the file object earlier in the pipeline. (Or, if you're using this plugin with [assemble] or [verb] you can define the draft property in front-matter.)

var gulp = require('gulp');
var drafts = require('gulp-drafts');

gulp.task('blog', function () {
  gulp.src('posts/**/*.md')
    // files with {draft: true} or {data: {draft: true}}
    // will be removed
    .pipe(drafts())
    .pipe(gulp.dest('dist'));
});

Ignore files with custom properties

var gulp = require('gulp');
var drafts = require('gulp-drafts');

gulp.task('blog', function () {
  gulp.src('posts/**/*.md')
    // ignore files with the `{foo: ...}` or `{bar: {baz: ...}}`
    // properties
    .pipe(drafts({props: ['foo', 'bar.baz']}))
    .pipe(gulp.dest('dist'));
});

Verb example

Everything works the same with [verb] and [assemble].

var verb = require('verb');
var drafts = require('verb-drafts');

verb.task('blog', function () {
  verb.src('posts/**/*.md')
    // ignore files with the `{foo: ...}` or `{bar: {baz: ...}}`
    // properties
    .pipe(drafts({props: ['foo', 'bar.baz']}))
    .pipe(verb.dest('dist'));
});

Run tests

Install dev dependencies:

node i -d && mocha

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 22, 2015.

Current Tags

  • 0.2.0                                ...           latest (5 years ago)

2 Versions

  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 6
Last Day 0
Last Week 6
Last Month 34
Dependencies (4)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |