A Gulp plugin for enforcing a character limit on file paths
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.editorconfig
.gitattributes
.gitignore
.npmignore
.travis.yml
README.md
appveyor.yml
gulpfile.coffee
package.json

README.md

gulp-path-length

NPM version Build Status Windows Build Status Dependency Status


A Gulp plugin for enforcing a character limit on file paths. Created with Windows' 256 character limit in mind but can be used on other platforms too.

Installation

npm install gulp-path-length

Usage

var gulp = require('gulp');
var pathLength = require('gulp-path-length');

gulp.task('default', function(){
    gulp.src('./example/path/to/directory/**', {read: false})
        .pipe(pathLength()); 
});

This will stop the build with an error if you've an overly long path. I've passed {read: false} to gulp.src here because we don't need to read the contents, we just need the paths. But if you're using gulp-path-length after some other pipes, it's likely you shouldn't pass {read: false}.

API

There is only one (optional) parameter; an options object. The possible properties it can contain are:

  • maxLength - defaults to 256
  • rewrite - This is an optional object which should contain match and replacement properties which contains mappings between directories. So for example:
rewrite: {
    match: './example/path/to/directory/',
    replacement: 'C:\\Program Files (x86)\\abc'
}

When the plugin goes to check the file ./example/path/to/directory/x.txt, it will actually check C:\Program Files (x86)\abc\x.txt.

  • rewrite.match accepts a path to resolve (like ./example), relative (example/a) or absolute paths (C:\a).
  • rewrite.replacement only accepts an absolute path.