-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
83 lines (71 loc) · 1.48 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* GruntFile.js example.
*
* grunt-codename
* https://github.com/scriptwerx/grunt-codename
*
* Copyright (c) 2014 scriptwerx
* Licensed under the MIT license.
*/
/* jslint todo: true, white: true */
/* global module */
var testJSON = "test.json";
module.exports = function (grunt)
{
"use strict";
/**
* Ensures single-digit bump occurs
* @param part
* @returns {string}
*/
function autoBump (part) {
if (part === "build") return ["bump:" + part];
var pkg = grunt.file.readJSON (testJSON),
versionData = pkg.version.split (".");
if (part === "patch" && parseInt (versionData[2], 10) + 1 >= 10) part = "minor";
if (part === "minor" && parseInt (versionData[1], 10) + 1 >= 10) part = "major";
return part;
}
grunt.initConfig ({
pkg: grunt.file.readJSON (testJSON),
bump: {
build: {
options: {
part: "build"
},
src: [testJSON]
},
patch: {
options: {
part: autoBump ("patch")
},
src: [testJSON]
},
minor: {
options: {
part: autoBump ("minor")
},
src: [testJSON]
},
major: {
options: {
part: "major"
},
src: [testJSON]
}
},
codename: {
all: {
options: {
patch: true,
data: grunt.file.readJSON ("codenames.json")
},
src: [testJSON]
}
}
});
grunt.loadNpmTasks ("grunt-bumpx");
grunt.loadNpmTasks ("grunt-codename");
// Default - Check code, concat, uglify and bump the build version.
grunt.registerTask ("default", ["bump:patch", "codename"]);
};