GithubHelp home page GithubHelp logo

osdio / gulp-version-tag Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 340 KB

A gulp plugin for add version num to file name and auto gain version num in package.json.

Home Page: http://soliury.github.io/gulp-version-tag

License: MIT License

CoffeeScript 12.49% JavaScript 87.51%

gulp-version-tag's Introduction

gulp-version-tag

NPM version Coverage Status Dependency Status

gulp-version-tag plugin for gulp.

Just for attach versionTag to your file. And it can auto gain the version number.

Usage

First, install gulp-version-tag as a development dependency:

npm install --save-dev gulp-version-tag

Then, add it to your gulpfile.js:

var gulp-version-tag = require("gulp-version-tag");

gulp.src("./src/*.js")
	.pipe(gulp-version-tag(__dirname,'./package.json'))
	.pipe(gulp.dest("./dist"));

API

gulp-version-tag(__dirname, packagejsonPath, [options])

__dirname

Type: String

Required: true

When using, just set the this param to __dirname.

Example:

gulp.task 'default', ->
	gulp.src '../test/**/**.txt'
	.pipe versionTag __dirname, '../test/package.json'
	.pipe gulp.dest './dest'

packagejsonPath

Type: String

Required: true

This is the relative path from where you use gulp-version-tag to the package.json.

Example:

Just see above example. And the file structrue for the example is :

example
    gulpfile.coffee
test
    package.json

And the gulp file.coffee is the example file.

options

Type: Object

Required: false

options.reuse

Type: Bool

Required: false

Default: true

If you set this value to true, when run gulp-version-tag, if global.versionTag have value, it will use the value of it as version. And once you run a task, it will set global.versionTag to the version read from package.json.

If you set this value to false, it won't check the value of global.versionTag every time you run a gulp task.

For example:

gulp.task 'task1', ->
	gulp.src '../test/expected/**.txt'
	.pipe versionTag __dirname, '../test/package.json',
#		reuse: false
		prefix: '-v'
		suffix: ''
#		autoSave:false
#		autoTagVersion: false
	.pipe gulp.dest './dest'

gulp.task 'task2', ->
	gulp.src '../test/fixtures/**.txt'
	.pipe versionTag __dirname, '../test/package.json',
#		reuse: false
		prefix: '-v'
		suffix: ''
#		autoSave:false
#		autoTagVersion: false
	.pipe gulp.dest './dest'


gulp.task 'default', ['task1', 'task2']

When you running many tasks, and you want to use the same version, you should not set reuse to false.Just like the example above, task1 and task2 can use the same version, it only auto gain version once, and save once.

For more example, just see my another project: ngFast.

options.prefix

Type: String

Default: '-v'

The text to add before version num.

options.suffix

Type: String

Default: ''

The text to add after version num.

Example:

gulp.task 'default', ->
	gulp.src '../test/**/**.txt'
	.pipe versionTag __dirname, '../test/package.json',
		global: true
		prefix: '---v'
		suffix: '---'
	.pipe gulp.dest './dest'

options.autoSave

Type: Bool

Default: true

If the value is true, When running gulp-version-tag, it will auto save the version change to package.json.

options.autoTagVersion

Type: Bool

Default: true

If the value is true, it will auto change the version number, if the version in your package.json is 0.0.1, a file file01 will be changed to file01-v0.0.02 after running.

For more example, just see.

options.type

Type: String

Default: patch

patch: v0.0.1 --> v0.0.2

feature: v0.0.1 --> v0.1.1

release: v0.0.1 --> v1.0.1

Another use

gulp = require 'gulp'
versionTag = require '../index'
Version = require '../util'


version = new Version __dirname, '../test/package.json',
	autoSave: true


gulp.task 'patch', ->
	version.patch()
	console.log "version changed to #{version.version}"

gulp.task 'feature', ->
	version.feature()
	console.log "version changed to #{version.version}"

gulp.task 'release', ->
	version.release()
	console.log "version changed to #{version.version}"

This can ease to update the package version. More details focus on gulpfile

License

MIT License

gulp-version-tag's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

krevelen

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.