Skip to content

Commit

Permalink
Merge branch 'master' into release-v8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 12, 2020
2 parents a316e37 + 267d78d commit 8dd8d06
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 82 deletions.
49 changes: 25 additions & 24 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "replacement for `npm version` with automatic CHANGELOG generation",
"bin": "bin/cli.js",
"scripts": {
"fix": "eslint . --fix",
"posttest": "eslint .",
"test": "nyc mocha --timeout=30000 test.js",
"release": "bin/cli.js"
Expand Down Expand Up @@ -34,35 +35,35 @@
},
"homepage": "https://github.com/conventional-changelog/standard-version#readme",
"dependencies": {
"chalk": "2.4.2",
"chalk": "^2.4.2",
"conventional-changelog": "3.1.21",
"conventional-changelog-config-spec": "2.1.0",
"conventional-changelog-conventionalcommits": "4.3.0",
"conventional-recommended-bump": "6.0.9",
"detect-indent": "6.0.0",
"detect-newline": "3.1.0",
"dotgitignore": "2.1.0",
"figures": "3.1.0",
"find-up": "4.1.0",
"fs-access": "1.0.1",
"git-semver-tags": "4.0.0",
"semver": "7.1.1",
"stringify-package": "1.0.1",
"yargs": "15.3.1"
"detect-indent": "^6.0.0",
"detect-newline": "^3.1.0",
"dotgitignore": "^2.1.0",
"figures": "^3.1.0",
"find-up": "^4.1.0",
"fs-access": "^1.0.1",
"git-semver-tags": "^4.0.0",
"semver": "^7.1.1",
"stringify-package": "^1.0.1",
"yargs": "^15.3.1"
},
"devDependencies": {
"chai": "4.2.0",
"coveralls": "3.1.0",
"eslint": "6.8.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.20.0",
"eslint-plugin-node": "10.0.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"mocha": "7.2.0",
"mock-git": "2.0.0",
"mockery": "2.1.0",
"nyc": "14.1.1",
"shelljs": "0.8.4"
"chai": "^4.2.0",
"coveralls": "^3.1.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"mocha": "^7.2.0",
"mock-git": "^2.0.0",
"mockery": "^2.1.0",
"nyc": "^14.1.1",
"shelljs": "^0.8.4"
}
}
6 changes: 5 additions & 1 deletion renovate.json
@@ -1,5 +1,9 @@
{
"extends": [
"config:base"
]
],
"pinVersions": false,
"rebaseStalePrs": true,
"gitAuthor": null,
"ignoreDeps": ["decamelize"]
}
119 changes: 62 additions & 57 deletions test.js
Expand Up @@ -13,6 +13,8 @@ const formatCommitMessage = require('./lib/format-commit-message')
const cli = require('./command')
const standardVersion = require('./index')

const isWindows = process.platform === 'win32'

require('chai').should()

const cliPath = path.resolve(__dirname, './bin/cli.js')
Expand Down Expand Up @@ -248,74 +250,77 @@ describe('cli', function () {
})
})

describe('with mocked git', function () {
it('--sign signs the commit and tag', function () {
// mock git with file that writes args to gitcapture.log
return mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")')
.then(function (unmock) {
execCli('--sign').code.should.equal(0)

const captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {
return line ? JSON.parse(line) : line
// TODO: investigate why mock-git does not play well with execFile on Windows.
if (!isWindows) {
describe('with mocked git', function () {
it('--sign signs the commit and tag', function () {
// mock git with file that writes args to gitcapture.log
return mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")')
.then(function (unmock) {
execCli('--sign').code.should.equal(0)

const captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {
return line ? JSON.parse(line) : line
})
/* eslint-disable no-useless-escape */
captured[captured.length - 4].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', '\"chore(release): 1.0.1\"'])
captured[captured.length - 3].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', '\"chore(release): 1.0.1\"'])
/* eslint-enable no-useless-escape */
unmock()
})
/* eslint-disable no-useless-escape */
captured[captured.length - 4].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', '\"chore(release): 1.0.1\"'])
captured[captured.length - 3].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', '\"chore(release): 1.0.1\"'])
/* eslint-enable no-useless-escape */
unmock()
})
})
})

it('exits with error code if git commit fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("commit yourself"); process.exit(128);', 'commit')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/commit yourself/)
it('exits with error code if git commit fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("commit yourself"); process.exit(128);', 'commit')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/commit yourself/)

unmock()
})
})
unmock()
})
})

it('exits with error code if git add fails', function () {
// mock git by throwing on attempt to add
return mockGit('console.error("addition is hard"); process.exit(128);', 'add')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/addition is hard/)
it('exits with error code if git add fails', function () {
// mock git by throwing on attempt to add
return mockGit('console.error("addition is hard"); process.exit(128);', 'add')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/addition is hard/)

unmock()
})
})
unmock()
})
})

it('exits with error code if git tag fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("tag, you\'re it"); process.exit(128);', 'tag')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/tag, you're it/)
it('exits with error code if git tag fails', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("tag, you\'re it"); process.exit(128);', 'tag')
.then(function (unmock) {
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/tag, you're it/)

unmock()
})
})
unmock()
})
})

it('doesn\'t fail fast on stderr output from git', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("haha, kidding, this is just a warning"); process.exit(0);', 'add')
.then(function (unmock) {
writePackageJson('1.0.0')
it('doesn\'t fail fast on stderr output from git', function () {
// mock git by throwing on attempt to commit
return mockGit('console.error("haha, kidding, this is just a warning"); process.exit(0);', 'add')
.then(function (unmock) {
writePackageJson('1.0.0')

const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/haha, kidding, this is just a warning/)
const result = execCli()
result.code.should.equal(1)
result.stderr.should.match(/haha, kidding, this is just a warning/)

unmock()
})
unmock()
})
})
})
})
}

describe('lifecycle scripts', () => {
describe('prerelease hook', function () {
Expand Down

0 comments on commit 8dd8d06

Please sign in to comment.