diff --git a/.travis.yml b/.travis.yml index 868f4373..15100f14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: node_js node_js: + - 12 - 10 - - 8 + - 8.3 # Trigger a push build on release and greenkeeper branches + PRs build on every branches # Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147) diff --git a/lib/git.js b/lib/git.js index 43e143aa..8340946d 100644 --- a/lib/git.js +++ b/lib/git.js @@ -11,7 +11,7 @@ const debug = require('debug')('semantic-release:git'); */ async function filterModifiedFiles(files, execaOpts) { return files.length > 0 - ? (await execa.stdout('git', ['ls-files', '-m', '-o', ...files], execaOpts)) + ? (await execa('git', ['ls-files', '-m', '-o', ...files], execaOpts)).stdout .split('\n') .map(file => file.trim()) .filter(file => Boolean(file)) @@ -61,8 +61,8 @@ async function push(origin, branch, execaOpts) { * * @return {String} The sha of the head commit on the local repository */ -function gitHead(execaOpts) { - return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts); +async function gitHead(execaOpts) { + return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; } module.exports = {filterModifiedFiles, add, gitHead, commit, push}; diff --git a/package.json b/package.json index 159328e1..09e97a0a 100644 --- a/package.json +++ b/package.json @@ -3,44 +3,45 @@ "description": "semantic-release plugin to commit release assets to the project's git repository", "version": "0.0.0-development", "author": "Pierre Vanduynslager (https://github.com/pvdlg)", + "ava": { + "files": [ + "test/**/*.test.js" + ], + "helpers": [ + "test/helpers/**/*" + ] + }, "bugs": { "url": "https://github.com/semantic-release/git/issues" }, - "config": { - "commitizen": { - "path": "cz-conventional-changelog" - } - }, "contributors": [ "Stephan Bönnemann (http://boennemann.me)", "Gregor Martynus (https://twitter.com/gr2m)" ], "dependencies": { "@semantic-release/error": "^2.1.0", - "aggregate-error": "^2.0.0", + "aggregate-error": "^3.0.0", "debug": "^4.0.0", - "dir-glob": "^2.0.0", + "dir-glob": "^3.0.0", "execa": "^1.0.0", - "fs-extra": "^7.0.0", - "globby": "^9.0.0", + "fs-extra": "^8.0.0", + "globby": "^10.0.0", "lodash": "^4.17.4", - "micromatch": "^3.1.4", - "p-reduce": "^1.0.0" + "micromatch": "^4.0.0", + "p-reduce": "^2.0.0" }, "devDependencies": { - "ava": "^1.0.1", - "clear-module": "^3.0.0", + "ava": "^2.0.0", + "clear-module": "^4.0.0", "codecov": "^3.0.0", - "commitizen": "^3.0.0", - "cz-conventional-changelog": "^2.0.0", - "file-url": "^2.0.2", - "get-stream": "^4.0.0", + "file-url": "^3.0.0", + "get-stream": "^5.0.0", "git-log-parser": "^1.2.0", - "nyc": "^13.1.0", + "nyc": "^14.0.0", "semantic-release": "^16.0.0-beta", "sinon": "^7.1.1", - "tempy": "^0.2.1", - "xo": "^0.24.0" + "tempy": "^0.3.0", + "xo": "^0.25.2" }, "engines": { "node": ">=8.3" @@ -89,7 +90,6 @@ "url": "https://github.com/semantic-release/git.git" }, "scripts": { - "cm": "git-cz", "codecov": "codecov -f coverage/coverage-final.json", "lint": "xo", "pretest": "npm run lint", diff --git a/test/git.test.js b/test/git.test.js index 9353f855..6c5d927b 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -94,5 +94,5 @@ test('Push commit to remote repository', async t => { await push(repositoryUrl, 'master', {cwd}); - t.is(await gitRemoteHead(repositoryUrl), hash, {cwd}); + t.is(await gitRemoteHead(repositoryUrl, {cwd}), hash); }); diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index e6a693f3..bc06b373 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -60,8 +60,10 @@ export async function initBareRepo(repositoryUrl, branch = 'master') { * @returns {Array} The created commits, in reverse order (to match `git log` order). */ export async function gitCommits(messages, execaOpts) { - await pReduce(messages, (_, message) => - execa.stdout('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts) + await pReduce( + messages, + async (_, message) => + (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout ); return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length); } @@ -89,10 +91,10 @@ export async function gitGetCommits(from, execaOpts) { * Checkout a branch on the current git repository. * * @param {String} branch Branch name. - * @param {Boolean} create `true` to create the branch, `false` to checkout an existing branch. + * @param {Boolean} create to create the branch, `false` to checkout an existing branch. * @param {Object} [execaOpts] Options to pass to `execa`. */ -export async function gitCheckout(branch, create = true, execaOpts) { +export async function gitCheckout(branch, create, execaOpts) { await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts); } @@ -151,7 +153,7 @@ export async function gitDetachedHead(repositoryUrl, head) { * @return {String} The HEAD sha of the remote repository. */ export async function gitRemoteHead(repositoryUrl, execaOpts) { - return (await execa.stdout('git', ['ls-remote', repositoryUrl, 'HEAD'], execaOpts)) + return (await execa('git', ['ls-remote', repositoryUrl, 'HEAD'], execaOpts)).stdout .split('\n') .filter(head => Boolean(head)) .map(head => head.match(/^(\S+)/)[1])[0]; @@ -165,7 +167,7 @@ export async function gitRemoteHead(repositoryUrl, execaOpts) { * @return {Array} Array of staged files path. */ export async function gitStaged(execaOpts) { - return (await execa.stdout('git', ['status', '--porcelain'], execaOpts)) + return (await execa('git', ['status', '--porcelain'], execaOpts)).stdout .split('\n') .filter(status => status.startsWith('A ')) .map(status => status.match(/^A\s+(.+)$/)[1]); @@ -174,13 +176,13 @@ export async function gitStaged(execaOpts) { /** * Get the list of files included in a commit. * - * @param {String} [ref='HEAD'] The git reference for which to retrieve the files. + * @param {String} ref The git reference for which to retrieve the files. * @param {Object} [execaOpts] Options to pass to `execa`. * * @return {Array} The list of files path included in the commit. */ -export async function gitCommitedFiles(ref = 'HEAD', execaOpts) { - return (await execa.stdout('git', ['diff-tree', '-r', '--name-only', '--no-commit-id', '-r', ref], execaOpts)) +export async function gitCommitedFiles(ref, execaOpts) { + return (await execa('git', ['diff-tree', '-r', '--name-only', '--no-commit-id', '-r', ref], execaOpts)).stdout .split('\n') .filter(file => Boolean(file)); }