'use strict';

var cwd = process.cwd();
var path = require('path');
var cmd = require('commander');
var fs = require('fs');
var pkg = require(path.join(cwd, '/package.json'));
var semver = require('semver');
var sh = require('shelljs');

function replace (file, pattern, replacement) {
  var str = fs.readFileSync(file).toString();
  str = str.replace(pattern, replacement);
  fs.writeFileSync(file, str);
};

cmd
  .option('-s, --semver [version]', 'The semantic version to release in lieu of --type. This takes precedence over --type.')
  .option('-t, --type [major, minor or patch]', 'The type of release being performed in lieu of --semver.')
  .parse(process.argv);

module.exports = function () {
  var currentVersion = pkg.version;
  var nextVersion = cmd.semver || semver.inc(
    currentVersion,
    cmd.type || 'patch'
  );

  console.log(currentVersion, nextVersion);

  // sh.exec('npm run lint');
  // sh.exec('npm run test');
  // replace('src/version.js', currentVersion, nextVersion);
  // replace('bower.json', currentVersion, nextVersion);
  // replace('package.json', currentVersion, nextVersion);
  // sh.exec('npm run build');
  // sh.exec('git commit -am "' + currentVersion + ' -> ' + nextVersion + '"');
  // sh.exec('git tag -a ' + nextVersion + ' -m ' + nextVersion);
  // sh.exec('git push');
  // sh.exec('git push --tags');
  // sh.exec('npm publish');
};

@@ -65,40 +65,8 @@
 ');%0A
-var cmd = require('commander');%0A
 var 
@@ -375,270 +375,8 @@
 %7D;%0A%0A
-cmd%0A  .option('-s, --semver %5Bversion%5D', 'The semantic version to release in lieu of --type. This takes precedence over --type.')%0A  .option('-t, --type %5Bmajor, minor or patch%5D', 'The type of release being performed in lieu of --semver.')%0A  .parse(process.argv);%0A%0A
 modu
@@ -458,19 +458,20 @@
 rsion = 
-cmd
+this
 .semver 
@@ -513,11 +513,12 @@
     
-cmd
+this
 .typ
@@ -541,56 +541,8 @@
 ;%0A%0A 
- console.log(currentVersion, nextVersion);%0A%0A  //
  sh.
@@ -560,27 +560,24 @@
 un lint');%0A 
- //
  sh.exec('np
@@ -587,27 +587,24 @@
 un test');%0A 
- //
  replace('sr
@@ -641,35 +641,32 @@
  nextVersion);%0A 
- //
  replace('bower.
@@ -703,19 +703,16 @@
 sion);%0A 
- //
  replace
@@ -751,35 +751,32 @@
  nextVersion);%0A 
- //
  sh.exec('npm ru
@@ -783,27 +783,24 @@
 n build');%0A 
- //
  sh.exec('gi
@@ -860,27 +860,24 @@
 on + '%22');%0A 
- //
  sh.exec('gi
@@ -923,27 +923,24 @@
 tVersion);%0A 
- //
  sh.exec('gi
@@ -946,27 +946,24 @@
 it push');%0A 
- //
  sh.exec('gi
@@ -984,11 +984,8 @@
 );%0A 
- //
  sh.

Update release task.