Permalink
Browse files

[publish] Fixed random error where it started DOS'ing fucking Github …

…servers with continuous updates.
  • Loading branch information...
1 parent d961890 commit f80b3bdd0637eb1d33b896367e7c25fce29a96d2 @larzconwell committed Sep 8, 2012
Showing with 20 additions and 20 deletions.
  1. +20 −20 lib/auto_npm.js
View
@@ -62,17 +62,17 @@ exports.getCommit = function (callback) {
exec(subjectCMD, function (err, stdout) {
if (err) {
- callback && callback(undefined, undefined, err);
+ callback && callback(err, undefined, undefined);
}
subject = stdout;
exec(diffCMD, function (err, stdout) {
if (err) {
- callback && callback(undefined, undefined, err);
+ callback && callback(err, undefined, undefined);
}
diff = stdout;
- callback && callback(diff, subject, undefined);
+ callback && callback(undefined, diff, subject);
});
});
};
@@ -168,18 +168,17 @@ exports.update = function () {
errors.gitError();
}
- var subjectPat = /\[publish\]/i
- , versionPat = /"version*":.*/i
- , pkg = exports.getPackage()
- , pkgVersion = pkg.version
- , cmds = []
- , incrementAndPush
- , tagAndPublish;
+ var subjectPat = /\[publish\]/i
+ , versionPat = /"version*":.*/i
+ , pkg = exports.getPackage()
+ , pkgVersion = pkg.version
+ , cmds = []
+ , incrementAndPush = {}
+ , tagAndPublish = {};
// Increment version write it to package.json then push to server
incrementAndPush = function () {
- var nums = pkgVersion.split('.')
- , pushCMDS = [];
+ var nums = pkgVersion.split('.');
// Increment patch number
nums[2] = Number(nums[2]) + 1
@@ -189,7 +188,7 @@ exports.update = function () {
fs.writeFileSync(packagePath, JSON.stringify(pkg, true, 2));
// Push to the server
- pushCMDS = [
+ cmds = [
'git commit package.json -m "Version ' + pkgVersion + '"'
, 'git push origin master'
];
@@ -227,20 +226,21 @@ exports.update = function () {
});
};
- exports.getCommit(function (diff, subject, err) {
+ exports.getCommit(function (err, diff, subject) {
if (err) {
- throw err;
+ utils.kill(err, 1);
}
- // If version has been updated in package.json just update NPM package and set up tags
- if (diff.match(versionPat) && diff.match("package.json")) {
+ // If subject includes [publish] increment and push update
+ if (subject.match(subjectPat)) {
+ incrementAndPush();
tagAndPublish();
}
- // If subject includes [publish]
- if (subject.match(subjectPat)) {
- incrementAndPush();
+ // If version has been updated in package.json just update NPM package and set up tags
+ if (diff.match(versionPat) && diff.match("package.json")) {
tagAndPublish();
}
+ process.exit(0);
});
};

0 comments on commit f80b3bd

Please sign in to comment.