module.exports = function (grunt) {
  var semver = require('semver');
  var version = grunt.option('version');

  function bump () {
    //console.log(arguments[0][0]);
  }

  function file (path) {
    return {
      dest: path,
      src: path
    };
  }

  function pattern (find) {
    return {
      match: find,
      replacement: bump
    };
  }

  return {
    release: {
      options: {
        patterns: [
          pattern(/version: '([^\']+)';/),
          pattern(/"version": "([^\']+)"/)
        ]
      },
      files: [
        file('src/version.js'),
        file('bower.json'),
        file('package.json')
      ]
    }
  };
};

module.exports = function (grunt) {
  var curver = require('../../package.json').version;
  var semver = require('semver');
  var version = grunt.option('version');

  function bump () {
    return version ? version : semver.inc(curver);
  }

  function file (path) {
    return {
      dest: path,
      src: path
    };
  }

  return {
    release: {
      options: {
        patterns: [
          {
            match: new RegExp(curver),
            replacement: bump
          }
        ]
      },
      files: [
        file('src/version.js'),
        file('bower.json'),
        file('package.json')
      ]
    }
  };
};

Use specified version or increment current version.