refactor(release) var -> const

This commit is contained in:
coderaiser 2016-07-28 21:32:18 +03:00
parent dbbf061121
commit 8d9f15ca3e

View file

@ -2,15 +2,15 @@
'use strict';
var DIR = '../',
Info = require(DIR + 'package'),
minor = require('minor'),
place = require('place'),
rendy = require('rendy'),
shortdate = require('shortdate'),
ERROR = Error('ERROR: version is missing. release --patch|--minor|--major');
const DIR = '../';
const Info = require(DIR + 'package');
const minor = require('minor');
const place = require('place');
const rendy = require('rendy');
const shortdate = require('shortdate');
const ERROR = Error('ERROR: version is missing. release --patch|--minor|--major');
main(function(error) {
if (error)
@ -18,12 +18,13 @@ main(function(error) {
});
function main(callback) {
var history = 'Version history\n---------------\n',
link = '//github.com/coderaiser/cloudcmd/releases/tag/',
template = '- *{{ date }}*, ' +
'**[v{{ version }}]' +
'(' + link + 'v{{ version }})**\n',
version = Info.version;
const history = 'Version history\n---------------\n';
const link = '//github.com/coderaiser/cloudcmd/releases/tag/';
const template = '- *{{ date }}*, ' +
'**[v{{ version }}]' +
'(' + link + 'v{{ version }})**\n';
const version = Info.version;
cl(function(error, versionNew) {
if (error) {
@ -31,7 +32,7 @@ function main(callback) {
} else {
replaceVersion('README.md', version, versionNew, callback);
replaceVersion('HELP.md', version, versionNew, function() {
var historyNew = history + rendy(template, {
const historyNew = history + rendy(template, {
date : shortdate(),
version : versionNew
});
@ -44,7 +45,7 @@ function main(callback) {
function replaceVersion(name, version, versionNew, callback) {
place(name, version, versionNew, function(error) {
var msg;
let msg;
if (!error)
msg = 'done: ' + name;
@ -54,17 +55,19 @@ function replaceVersion(name, version, versionNew, callback) {
}
function cl(callback) {
var versionNew, error,
argv = process.argv,
length = argv.length - 1,
last = process.argv[length],
regExp = /^--(major|minor|patch)$/,
match = last.match(regExp);
const argv = process.argv;
const length = argv.length - 1;
const last = process.argv[length];
const regExp = /^--(major|minor|patch)$/;
const [, match] = last.match(regExp) || [];
let error;
let versionNew;
if (!regExp.test(last))
error = ERROR;
else if (match[1])
versionNew = minor(match[1], Info.version);
else if (match)
versionNew = minor(match, Info.version);
else
versionNew = last.substr(3);