'use strict';

var cmd = require('commander');
var pkg = require('../lib/package');
var replace = require('../lib/replace');
var semver = require('semver');
var sh = require('shelljs');

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'
  );

  sh.exec('npm run lint');
  sh.exec('npm run test');
  replace('bower.json', currentVersion, nextVersion);
  replace('package.json', currentVersion, nextVersion);
  sh.exec('npm run dist');
  sh.exec('npm run lib');
  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');
};

@@ -616,23 +616,20 @@
 h.exec('
-npm run
+gulp
  lint');
@@ -640,23 +640,20 @@
 h.exec('
-npm run
+gulp
  test');
@@ -774,23 +774,20 @@
 h.exec('
-npm run
+gulp
  dist');
@@ -802,15 +802,12 @@
 ec('
-npm run
+gulp
  lib

Use gulp command instead of npm run because that requires them to have the scripts entries in the package.json.