Socket
Socket
Sign inDemoInstall

gulp-dependencies-changed

Package Overview
Dependencies
13
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-dependencies-changed

Smart incremental building by dependency analysis


Version published
Weekly downloads
1.3K
increased by19.71%
Maintainers
2
Install size
2.05 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 05 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc