MCPcopy Create free account
hub / github.com/socketstream/socketstream / setVersion

Function setVersion

Gruntfile.js:134–153  ·  view source on GitHub ↗

* Sets version in 'package.json' in http://semver.org friendly mode * * @param {String} type Could be 'major', 'minor' or 'patch' * @param {String} suffix Suffic string, example: 'alpha', 'pre-alpha', 'beta'

(type, suffix)

Source from the content-addressed store, hash-verified

132 * @param {String} suffix Suffic string, example: 'alpha', 'pre-alpha', 'beta'
133 */
134 function setVersion(type, suffix) {
135 var file = 'package.json',
136 VERSION_REGEX = /([\'|\"]version[\'|\"][ ]*:[ ]*[\'|\"])([\d|.]*)(-\w+)*([\'|\"])/,
137 contents = grunt.file.read(file),
138 version;
139 contents = contents.replace(VERSION_REGEX, function(match, left, center) {
140 version = center;
141 if (type) {
142 version = require('semver').inc(version, type);
143 }
144 //semver.inc strips our suffix if it existed
145 if (suffix) {
146 version += '-' + suffix;
147 }
148 return left + version + '"';
149 });
150 grunt.log.ok('Version set to ' + version.cyan);
151 grunt.file.write(file, contents);
152 return version;
153 }
154
155 /**
156 * Task for setting project version according to http://semver.org

Callers 1

Gruntfile.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected