Skip to content

Gulp plugin for pulling versioning from a file and add it to the filename. Particularly useful for doing semvers on your JS libraries and CSS files.

Notifications You must be signed in to change notification settings

brwnll/gulp-version-filename

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gulp Version Filename circle ci code climate Test Coverage npm version

Takes the version number from within a file and adds it to the filename. This is specifically useful for pipelines outputting JS or CSS files. Allows for versioning controlled by you, instead of a hash, allowing for the use of human understandable sequencing (such as semver).

eg: myjslibrary-2.1.0.min.js

How to Use

Install module.

npm i gulp-version-filename

Somewhere Within Your CSS/JS/etc File

/**
 * My File
 * @version 8.12.12
 */

gulpfile.js

var filever = require('gulp-version-filename');

/**
 * Takes the version number and adds it to the filename
 */
gulp.task('rename', function() {
  return gulp.src(['newcssfile.css'])
    .pipe(filever())
    .pipe(gulp.dest('dist'));
});
gulp rename

You should now have

dist/newcssfile-8.12.12.css

Options

  • key

    Pass to change the version variable tag within the file, defaults to 'version'

  • silent

    Pass to suppress errors thrown if the version parameter is not found within a file.

gulp.task('rename', function() {
  return gulp.src(['*.css', '*.js'])
    .filever({
      key: 'package', // Searches for @package
      silent: true // Suppress errors if file is missing @package
    })
    .pipe(gulp.dest('dist'));
});

About

Gulp plugin for pulling versioning from a file and add it to the filename. Particularly useful for doing semvers on your JS libraries and CSS files.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •