npm

Need private packages and team management tools?Check out npm Orgs. »

gulp-dependencies-changed

1.0.2 • Public • Published

gulp-dependencies-changed

Build Status npm version

Smart incremental building by dependency analysis.

Installation

npm install --save-dev gulp-dependencies-changed

Usage

var less = require('gulp-less');
var changed = require('gulp-dependencies-changed');
var Path = require('path');
var rename = require('rename');
 
gulp.task('less', function() {
  return gulp.src('./less/**/*.less')
    // Analyze dependencies for less. Pass through
    // only files that its depending files are changed.
    .pipe(changed({
      matcher: /@import ['"]?([^'"]+)['"]?;/g,
      dest: function(srcRelPath, srcBasePath) {
        // It should return dest file path.
        return rename(srcPath, function(fileObj) {
          return {
            dirname: Path.join('public/css' + fileObj.dirname)
            extname: 'css',
          };
        });
      },
    }))
    .pipe(less())
    .pipe(gulp.dest('./public/css'));
});

API

changed(options)

Only pass through dependent files that depending to changed files

options

matcher

Type: RegExp

This RegExp MUST include only a capturing group and SHOULD be global match. The result of the match will be given to a pathResolver.

dest

Type: function(string, string): string

This function take an argument (a relative file path and the base path). The source file path is exactly equivalent to path.relative(vinylFile.path, vinylFile.base). It SHOULD return the file path for the dest file path. The return value is used as a target of comparison.

You can easily rename by using rename.

pathResolver

Type: function(string, string): string

Default: changed.relativeResolver

This function take 2 arguments (a dependent file path, the depended file path captured by matcher) and MUST return a file path for the depending file. If omitted, it takes a related file path from the dependent file.

If file extensions is omitted, you can complement the file extensions by the function.

comparator

Type: function(VinylFile, VinylFile): boolean

Default: changed.compareByMtime

This function take 2 arguments (a depending file and the dependent file) and it MUST return true when the depending is newer than the dependent file. If omitted, it compare by the both mtime.

debug

Type: boolean

Default: false

Print debug messages when it is truthy.

License

MIT

install

npm i gulp-dependencies-changed

Downloadsweekly downloads

108

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability