1
- module . exports = function ( config ) {
1
+ module . exports = function ( config ) {
2
2
var gulp = require ( 'gulp' ) ;
3
3
var runSequence = require ( 'run-sequence' ) ;
4
4
var conventionalChangelog = require ( 'gulp-conventional-changelog' ) ;
@@ -9,7 +9,7 @@ module.exports = function(config) {
9
9
var minimist = require ( 'minimist' ) ;
10
10
11
11
config = config || { } ;
12
-
12
+
13
13
var defaultOptions = {
14
14
string : 'env' ,
15
15
default : {
@@ -18,7 +18,7 @@ module.exports = function(config) {
18
18
branch : config . branch || 'master' ,
19
19
bump : config . bump || 'patch' ,
20
20
message : config . message || 'Release %VERSION%' ,
21
- version : config . version
21
+ tag : config . tag
22
22
}
23
23
} ;
24
24
@@ -32,37 +32,21 @@ module.exports = function(config) {
32
32
return gulp . src ( 'CHANGELOG.md' , {
33
33
buffer : false
34
34
} )
35
- . pipe ( conventionalChangelog ( {
36
- preset : 'eslint'
37
- } ) )
38
- . pipe ( gulp . dest ( './' ) ) ;
35
+ . pipe ( conventionalChangelog ( {
36
+ preset : 'eslint'
37
+ } ) )
38
+ . pipe ( gulp . dest ( './' ) ) ;
39
39
} ) ;
40
40
41
41
/**
42
42
* A task to bump package.json version
43
43
**/
44
44
gulp . task ( 'build:bump-version' , function ( ) {
45
45
return gulp . src ( options . sources )
46
- . pipe ( bump ( options . version ? { version : options . version } : { type : options . bump } ) . on ( 'error' , gutil . log ) )
46
+ . pipe ( bump ( options . tag ? { version : options . tag } : { type : options . bump } ) . on ( 'error' , gutil . log ) )
47
47
. pipe ( gulp . dest ( './' ) ) ;
48
48
} ) ;
49
49
50
- /**
51
- * A task to set package.json version
52
- **/
53
- gulp . task ( 'build:set-version' , function ( cb ) {
54
- if ( ! options . version ) {
55
- return cb ( 'No version argument!' ) ;
56
- }
57
-
58
- // FIXME: this does nothing!
59
- var verKey = options . version_key || 'version' ;
60
- var regex = opts . regex || new RegExp (
61
- '([\'|\"]?' + verKey + '[\'|\"]?[ ]*:[ ]*[\'|\"]?)(\\d+\\.\\d+\\.\\d+(-' +
62
- options . version_preid +
63
- '\\.\\d+)?(-\\d+)?)[\\d||A-a|.|-]*([\'|\"]?)' , 'i' ) ;
64
- } ) ;
65
-
66
50
/**
67
51
* A task to commit all changes in current workspace.
68
52
**/
@@ -83,7 +67,7 @@ module.exports = function(config) {
83
67
* Create a tag for the current version where version is taken from the package.json file
84
68
**/
85
69
gulp . task ( 'build:create-new-tag' , function ( cb ) {
86
- var version = options . version || getPackageJsonVersion ( ) ;
70
+ var version = options . tag || getPackageJsonVersion ( ) ;
87
71
git . tag ( version , options . message . replace ( '%VERSION%' , getPackageJsonVersion ( ) ) , function ( error ) {
88
72
if ( error ) {
89
73
return cb ( error ) ;
@@ -109,7 +93,7 @@ module.exports = function(config) {
109
93
} ) ;
110
94
} ) ;
111
95
112
- function getPackageJsonVersion ( ) {
96
+ function getPackageJsonVersion ( ) {
113
97
// We parse the json file instead of using require because require caches
114
98
// multiple calls so the version number won't be updated
115
99
return JSON . parse ( fs . readFileSync ( './package.json' , 'utf8' ) ) . version ;
0 commit comments