Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Updates var usage to let #321

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "standard",
"rules": {
"no-var": "error"
}
}
2 changes: 1 addition & 1 deletion command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var defaults = require('./defaults')
let defaults = require('./defaults')

module.exports = require('yargs')
.usage('Usage: $0 [options]')
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module.exports = function standardVersion (argv) {
let pkg
bump.pkgFiles.forEach((filename) => {
if (pkg) return
var pkgPath = path.resolve(process.cwd(), filename)
let pkgPath = path.resolve(process.cwd(), filename)
try {
var data = fs.readFileSync(pkgPath, 'utf8')
let data = fs.readFileSync(pkgPath, 'utf8')
pkg = JSON.parse(data)
} catch (err) {}
})
Expand Down
24 changes: 12 additions & 12 deletions lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const semver = require('semver')
const stringifyPackage = require('stringify-package')
const writeFile = require('../write-file')

var configsToUpdate = {}
let configsToUpdate = {}

function Bump (args, version) {
// reset the cache of updated config files each
// time we perform the version bump step.
configsToUpdate = {}

if (args.skip.bump) return Promise.resolve()
var newVersion = version
let newVersion = version
return runLifecycleScript(args, 'prerelease')
.then(runLifecycleScript.bind(this, args, 'prebump'))
.then((stdout) => {
Expand All @@ -31,7 +31,7 @@ function Bump (args, version) {
})
.then((release) => {
if (!args.firstRelease) {
var releaseType = getReleaseType(args.prerelease, release.releaseType, version)
let releaseType = getReleaseType(args.prerelease, release.releaseType, version)
newVersion = semver.valid(releaseType) || semver.inc(version, releaseType, args.prerelease)
updateConfigs(args, newVersion)
} else {
Expand Down Expand Up @@ -100,7 +100,7 @@ function isInPrerelease (version) {
return Array.isArray(semver.prerelease(version))
}

var TypeList = ['major', 'minor', 'patch'].reverse()
let TypeList = ['major', 'minor', 'patch'].reverse()

/**
* extract the in-pre-release type in target version
Expand All @@ -109,8 +109,8 @@ var TypeList = ['major', 'minor', 'patch'].reverse()
* @return {string}
*/
function getCurrentActiveType (version) {
var typelist = TypeList
for (var i = 0; i < typelist.length; i++) {
let typelist = TypeList
for (let i = 0; i < typelist.length; i++) {
if (semver[typelist[i]](version)) {
return typelist[i]
}
Expand Down Expand Up @@ -163,13 +163,13 @@ function updateConfigs (args, newVersion) {
Object.keys(configsToUpdate).forEach(function (configPath) {
try {
if (dotgit.ignore(configPath)) return
var stat = fs.lstatSync(configPath)
let stat = fs.lstatSync(configPath)
if (stat.isFile()) {
var data = fs.readFileSync(configPath, 'utf8')
var indent = detectIndent(data).indent
var newline = detectNewline(data)
var config = JSON.parse(data)
var filename = path.basename(configPath)
let data = fs.readFileSync(configPath, 'utf8')
let indent = detectIndent(data).indent
let newline = detectNewline(data)
let config = JSON.parse(data)
let filename = path.basename(configPath)
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])
config.version = newVersion
writeFile(args, configPath, stringifyPackage(config, indent, newline))
Expand Down
10 changes: 5 additions & 5 deletions lib/lifecycles/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ module.exports = function (args, newVersion) {
function outputChangelog (args, newVersion) {
return new Promise((resolve, reject) => {
createIfMissing(args)
var header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
var oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
let header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
let oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
// find the position of the last release and remove header:
if (oldContent.indexOf('<a name=') !== -1) {
oldContent = oldContent.substring(oldContent.indexOf('<a name='))
}
var content = ''
var context
let content = ''
let context
if (args.dryRun) context = { version: newVersion }
var changelogStream = conventionalChangelog({
let changelogStream = conventionalChangelog({
debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
preset: args.preset || 'angular',
tagPrefix: args.tagPrefix
Expand Down
8 changes: 4 additions & 4 deletions lib/lifecycles/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = function (args, newVersion) {
}

function execCommit (args, newVersion) {
var msg = 'committing %s'
var paths = [args.infile]
var verify = args.verify === false || args.n ? '--no-verify ' : ''
var toAdd = ''
let msg = 'committing %s'
let paths = [args.infile]
let verify = args.verify === false || args.n ? '--no-verify ' : ''
let toAdd = ''
// commit any of the config files that we've updated
// the version # for.
Object.keys(bump.getUpdatedConfigs()).forEach(function (p) {
Expand Down
4 changes: 2 additions & 2 deletions lib/lifecycles/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function (newVersion, pkgPrivate, args) {
}

function execTag (newVersion, pkgPrivate, args) {
var tagOption
let tagOption
if (args.sign) {
tagOption = '-s '
} else {
Expand All @@ -26,7 +26,7 @@ function execTag (newVersion, pkgPrivate, args) {
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
.then(() => {
var message = 'git push --follow-tags origin master'
let message = 'git push --follow-tags origin master'
if (pkgPrivate !== true) {
message += ' && npm publish'
if (args.prerelease !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion lib/run-lifecycle-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const runExec = require('./run-exec')

module.exports = function (args, hookName, newVersion, hooks, cb) {
if (!hooks[hookName]) return Promise.resolve()
var command = hooks[hookName] + ' --new-version="' + newVersion + '"'
let command = hooks[hookName] + ' --new-version="' + newVersion + '"'
checkpoint(args, 'Running lifecycle hook "%s"', [hookName])
checkpoint(args, '- hook command: "%s"', [command], chalk.blue(figures.info))
return runExec(args, command)
Expand Down
2 changes: 1 addition & 1 deletion lib/run-lifecycle-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const runExec = require('./run-exec')
module.exports = function (args, hookName) {
const scripts = args.scripts
if (!scripts || !scripts[hookName]) return Promise.resolve()
var command = scripts[hookName]
let command = scripts[hookName]
checkpoint(args, 'Running lifecycle script "%s"', [hookName])
checkpoint(args, '- execute command: "%s"', [command], chalk.blue(figures.info))
return runExec(args, command)
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "replacement for `npm version` with automatic CHANGELOG generation",
"bin": "bin/cli.js",
"scripts": {
"pretest": "standard",
"pretest": "eslint .",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test": "nyc mocha --timeout=20000 test.js",
"release": "bin/cli.js"
Expand Down Expand Up @@ -54,11 +54,16 @@
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^3.0.1",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"mocha": "^5.2.0",
"mock-git": "^1.0.3",
"mockery": "^2.0.0",
"nyc": "^13.3.0",
"shelljs": "^0.7.8",
"standard": "^12.0.1"
"shelljs": "^0.7.8"
}
}
Loading