Skip to content

Commit

Permalink
[++] publish tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tenbits committed Sep 4, 2013
1 parent a53dbee commit 9196f3f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions build/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

include.exports = publish;


function publish(done) {

var file = new io.File('package.json'),
pckg = file.read();



pckg.version = increaseVersion(pckg.version);

if (pckg.version == null) {
logger.log('Invalid package', pckg);
done('Invalid version');
return;
}

file.write(pckg);


app
.findAction('shell')
.done(function(handler){
handler.process({
command: [
'npm publish',
'git add -u',
'git commit -am build:' + pckg.version,
'git push origin master'
]}, done
);
});
}

function increaseVersion(version) {
if (typeof version !== 'string')
return null;


var parts = version
.split('.')
.map(function(x){ return x << 0});

if (parts.length !== 3) {
logger.log('Invalid ver. pattern', version);
return null;
}

if (++parts[2] > 100) {
if (++parts[1] > 100) {
++parts[0];
parts[1] = 0;
}
parts[2] = 0;
}

return parts.join('.');
}
1 change: 1 addition & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
atma custom build/process --publish

0 comments on commit 9196f3f

Please sign in to comment.