mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(gulp) changelog: add from npm
This commit is contained in:
parent
746d56a7a8
commit
ba06cf0ff1
2 changed files with 9 additions and 72 deletions
|
|
@ -2,29 +2,12 @@
|
|||
'use strict';
|
||||
|
||||
var DIR = '../../',
|
||||
fs = require('fs'),
|
||||
exec = require('child_process').exec,
|
||||
|
||||
changelog = require('changelog-io'),
|
||||
cl = require('../cl'),
|
||||
Util = require(DIR + 'lib/util'),
|
||||
Info = require(DIR + 'package');
|
||||
|
||||
module.exports = function() {
|
||||
var version = 'v' + Info.version,
|
||||
name = 'ChangeLog',
|
||||
|
||||
gitTempl = 'git log {{ version }}..HEAD --pretty=format:"- %s" --grep {{ category }} | sed \'s/{{ category }}//g\'',
|
||||
|
||||
gitFix = Util.render(gitTempl, {
|
||||
category : 'fix' ,
|
||||
version : version
|
||||
}),
|
||||
|
||||
gitFeature = Util.render(gitTempl, {
|
||||
category: 'feature',
|
||||
version : version
|
||||
}),
|
||||
|
||||
versionNew = cl.getVersion();
|
||||
|
||||
if (versionNew)
|
||||
|
|
@ -32,58 +15,11 @@
|
|||
else
|
||||
versionNew = version + '?';
|
||||
|
||||
fs.readFile(name, 'utf8', function(error, fileData) {
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT')
|
||||
console.log('ChangeLog read error. Would be created.');
|
||||
}
|
||||
|
||||
Util.exec.parallel([
|
||||
Util.exec.with(exec, gitFix),
|
||||
Util.exec.with(exec, gitFeature),
|
||||
], function(error, fixData, featureData) {
|
||||
var fix, feature,
|
||||
DATA = 0,
|
||||
STD_ERR = 1,
|
||||
date = Util.getShortDate(),
|
||||
head = date + ', ' + versionNew + '\n\n',
|
||||
data = '';
|
||||
|
||||
if (!error) {
|
||||
fix = fixData[DATA];
|
||||
feature = featureData[DATA];
|
||||
}
|
||||
|
||||
if (fix || feature) {
|
||||
data = head;
|
||||
|
||||
if (fix) {
|
||||
data += 'fix:' + '\n';
|
||||
data += fix + '\n';
|
||||
}
|
||||
|
||||
if (feature) {
|
||||
data += 'feature:' + '\n';
|
||||
data += feature + '\n';
|
||||
}
|
||||
|
||||
if (fileData)
|
||||
data += '\n\n' + fileData;
|
||||
}
|
||||
|
||||
error = error || fixData[STD_ERR] || featureData[STD_ERR];
|
||||
|
||||
if (error)
|
||||
console.error(error);
|
||||
else if (!data)
|
||||
console.log('No new feature and fix commits from v', version);
|
||||
else
|
||||
fs.writeFile(name, data, function(error) {
|
||||
var msg = 'changelog: done';
|
||||
|
||||
console.log(error || msg);
|
||||
});
|
||||
});
|
||||
changelog(versionNew, function(error, msg) {
|
||||
if (error)
|
||||
console.error(error.message);
|
||||
else
|
||||
console.log(msg);
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -41,12 +41,13 @@
|
|||
"tar": "~1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"changelog-io": "~1.2.1",
|
||||
"gulp": "~3.8.x",
|
||||
"gulp-jshint": "~1.8.4",
|
||||
"gulp-mocha": "~1.1.0",
|
||||
"gulp-recess": "~1.0.0",
|
||||
"should": "~4.0.x",
|
||||
"morgan": "~1.4.0"
|
||||
"morgan": "~1.4.0",
|
||||
"should": "~4.0.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6.x"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue