Coder Social home page Coder Social logo

gulp-inject-version's Introduction

gulp-inject-version

Gulp plugin for reading a version number out of a JSON file and injecting it into text based files.

By default, this plugin will read the version property from your project's package.json. It will then search the content of all files in the stream for the text %%GULP_INJECT_VERSION%% and replace that text with vX.Y.Z (where X.Y.Z is the version number it read from package.json).

installation

npm install gulp-inject-version

usage

var injectVersion = require('gulp-inject-version');

gulp.task('build', function () {
    return gulp.src('src/index.html')
        .pipe(injectVersion())
        // whatever else you want to do to index.html...
        .pipe(gulp.dest('dist'));
});

In this usage example, if src/index.html contained the html

<div class="footer">My Project %%GULP_INJECT_VERSION%%</div>

and the version property in your project's package.json was set to '1.0.3', then after running you'd find that dist/index.html now contains the replacement text:

<div class="footer">My Project v1.0.3</div>

options

An options object can be passed into the plugin like so:

var injectVersion = require('gulp-inject-version');

gulp.task('build', function () {
    return gulp.src('src/index.html')
        .pipe(injectVersion({
            package_file: 'bower.json',
            // your other option overrides here
        }))
        // whatever else you want to do to index.html...
        .pipe(gulp.dest('dist'));
});

Option properties that you can override are:

Option property type description default value
package_file string The JSON containing file from which we should read the version 'package.json'
version_property string The name of the property that holds the version text within the JSON file 'version'
prepend string A string to prepend to the outputted version text 'v'
append string A string to append to the outputted version text ''
replace string The placeholder text to be replaced with the version text in the source files '%%GULP_INJECT_VERSION%%'

gulp-inject-version's People

Contributors

jaaulde avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.