Skip to content

Commit

Permalink
chore(package): update ava to version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
greenkeeper[bot] authored and pvdlg committed Jan 27, 2020
1 parent e38f98d commit 3c1eb83
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 44 deletions.
5 changes: 1 addition & 4 deletions package.json
Expand Up @@ -6,9 +6,6 @@
"ava": {
"files": [
"test/**/*.test.js"
],
"helpers": [
"test/helpers/**/*"
]
},
"bugs": {
Expand All @@ -29,7 +26,7 @@
"p-reduce": "^2.0.0"
},
"devDependencies": {
"ava": "^2.0.0",
"ava": "^3.1.0",
"clear-module": "^4.0.0",
"codecov": "^3.0.0",
"file-url": "^3.0.0",
Expand Down
10 changes: 5 additions & 5 deletions test/git.test.js
@@ -1,8 +1,8 @@
import path from 'path';
import test from 'ava';
import {outputFile, appendFile} from 'fs-extra';
import {add, getModifiedFiles, commit, gitHead, push} from '../lib/git';
import {gitRepo, gitCommits, gitGetCommits, gitStaged, gitRemoteHead} from './helpers/git-utils';
const path = require('path');
const test = require('ava');
const {outputFile, appendFile} = require('fs-extra');
const {add, getModifiedFiles, commit, gitHead, push} = require('../lib/git');
const {gitRepo, gitCommits, gitGetCommits, gitStaged, gitRemoteHead} = require('./helpers/git-utils');

test('Add file to index', async t => {
// Create a git repository, set the current working directory at the root of the repo
Expand Down
54 changes: 35 additions & 19 deletions test/helpers/git-utils.js
@@ -1,9 +1,9 @@
import tempy from 'tempy';
import execa from 'execa';
import fileUrl from 'file-url';
import pReduce from 'p-reduce';
import gitLogParser from 'git-log-parser';
import getStream from 'get-stream';
const tempy = require('tempy');
const execa = require('execa');
const fileUrl = require('file-url');
const pReduce = require('p-reduce');
const gitLogParser = require('git-log-parser');
const getStream = require('get-stream');

/**
* Create a temporary git repository.
Expand All @@ -14,7 +14,7 @@ import getStream from 'get-stream';
* @param {String} [branch='master'] The branch to initialize.
* @return {String} The path of the clone if `withRemote` is `true`, the path of the repository otherwise.
*/
export async function gitRepo(withRemote, branch = 'master') {
async function gitRepo(withRemote, branch = 'master') {
let cwd = tempy.directory();

await execa('git', ['init'].concat(withRemote ? ['--bare'] : []), {cwd});
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function gitRepo(withRemote, branch = 'master') {
* @param {String} repositoryUrl The URL of the bare repository.
* @param {String} [branch='master'] the branch to initialize.
*/
export async function initBareRepo(repositoryUrl, branch = 'master') {
async function initBareRepo(repositoryUrl, branch = 'master') {
const cwd = tempy.directory();
await execa('git', ['clone', '--no-hardlinks', repositoryUrl, cwd], {cwd});
await gitCheckout(branch, true, {cwd});
Expand All @@ -59,7 +59,7 @@ export async function initBareRepo(repositoryUrl, branch = 'master') {
*
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
*/
export async function gitCommits(messages, execaOpts) {
async function gitCommits(messages, execaOpts) {
await pReduce(
messages,
async (_, message) =>
Expand All @@ -76,7 +76,7 @@ export async function gitCommits(messages, execaOpts) {
*
* @return {Array<Object>} The list of parsed commits.
*/
export async function gitGetCommits(from, execaOpts) {
async function gitGetCommits(from, execaOpts) {
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
return (
await getStream.array(
Expand All @@ -96,7 +96,7 @@ export async function gitGetCommits(from, execaOpts) {
* @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, execaOpts) {
async function gitCheckout(branch, create, execaOpts) {
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts);
}

Expand All @@ -107,7 +107,7 @@ export async function gitCheckout(branch, create, execaOpts) {
* @param {String} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
export async function gitTagVersion(tagName, sha, execaOpts) {
async function gitTagVersion(tagName, sha, execaOpts) {
await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOpts);
}

Expand All @@ -120,7 +120,7 @@ export async function gitTagVersion(tagName, sha, execaOpts) {
* @param {Number} [depth=1] The number of commit to clone.
* @return {String} The path of the cloned repository.
*/
export async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) {
async function gitShallowClone(repositoryUrl, branch = 'master', depth = 1) {
const cwd = tempy.directory();

await execa('git', ['clone', '--no-hardlinks', '--no-tags', '-b', branch, '--depth', depth, repositoryUrl, cwd], {
Expand All @@ -136,7 +136,7 @@ export async function gitShallowClone(repositoryUrl, branch = 'master', depth =
* @param {Number} head A commit sha of the remote repo that will become the detached head of the new one.
* @return {String} The path of the new repository.
*/
export async function gitDetachedHead(repositoryUrl, head) {
async function gitDetachedHead(repositoryUrl, head) {
const cwd = tempy.directory();

await execa('git', ['init'], {cwd});
Expand All @@ -154,7 +154,7 @@ export async function gitDetachedHead(repositoryUrl, head) {
*
* @return {String} The HEAD sha of the remote repository.
*/
export async function gitRemoteHead(repositoryUrl, execaOpts) {
async function gitRemoteHead(repositoryUrl, execaOpts) {
return (await execa('git', ['ls-remote', repositoryUrl, 'HEAD'], execaOpts)).stdout
.split('\n')
.filter(head => Boolean(head))
Expand All @@ -168,7 +168,7 @@ export async function gitRemoteHead(repositoryUrl, execaOpts) {
*
* @return {Array<String>} Array of staged files path.
*/
export async function gitStaged(execaOpts) {
async function gitStaged(execaOpts) {
return (await execa('git', ['status', '--porcelain'], execaOpts)).stdout
.split('\n')
.filter(status => status.startsWith('A '))
Expand All @@ -183,7 +183,7 @@ export async function gitStaged(execaOpts) {
*
* @return {Array<String>} The list of files path included in the commit.
*/
export async function gitCommitedFiles(ref, execaOpts) {
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));
Expand All @@ -195,7 +195,7 @@ export async function gitCommitedFiles(ref, execaOpts) {
* @param {Array<String>} files Array of files path to add to the index.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
export async function gitAdd(files, execaOpts) {
async function gitAdd(files, execaOpts) {
await execa('git', ['add', '--force', '--ignore-errors', ...files], {...execaOpts});
}

Expand All @@ -206,6 +206,22 @@ export async function gitAdd(files, execaOpts) {
* @param {String} branch The branch to push.
* @param {Object} [execaOpts] Options to pass to `execa`.
*/
export async function gitPush(repositoryUrl, branch, execaOpts) {
async function gitPush(repositoryUrl, branch, execaOpts) {
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts);
}

module.exports = {
gitRepo,
initBareRepo,
gitCommits,
gitGetCommits,
gitCheckout,
gitTagVersion,
gitShallowClone,
gitDetachedHead,
gitRemoteHead,
gitStaged,
gitCommitedFiles,
gitAdd,
gitPush,
};
16 changes: 8 additions & 8 deletions test/integration.test.js
@@ -1,18 +1,18 @@
import path from 'path';
import test from 'ava';
import {outputFile} from 'fs-extra';
import {stub} from 'sinon';
import clearModule from 'clear-module';
import {push, add} from '../lib/git';
import {
const path = require('path');
const test = require('ava');
const {outputFile} = require('fs-extra');
const {stub} = require('sinon');
const clearModule = require('clear-module');
const {push, add} = require('../lib/git');
const {
gitRepo,
gitCommits,
gitShallowClone,
gitDetachedHead,
gitCommitedFiles,
gitGetCommits,
gitTagVersion,
} from './helpers/git-utils';
} = require('./helpers/git-utils');

test.beforeEach(t => {
// Clear npm cache to refresh the module state
Expand Down
12 changes: 6 additions & 6 deletions test/prepare.test.js
@@ -1,9 +1,9 @@
import path from 'path';
import test from 'ava';
import {outputFile, remove} from 'fs-extra';
import {stub} from 'sinon';
import prepare from '../lib/prepare';
import {gitRepo, gitGetCommits, gitCommitedFiles, gitAdd, gitCommits, gitPush} from './helpers/git-utils';
const path = require('path');
const test = require('ava');
const {outputFile, remove} = require('fs-extra');
const {stub} = require('sinon');
const prepare = require('../lib/prepare');
const {gitRepo, gitGetCommits, gitCommitedFiles, gitAdd, gitCommits, gitPush} = require('./helpers/git-utils');

test.beforeEach(t => {
// Stub the logger functions
Expand Down
4 changes: 2 additions & 2 deletions test/verify.test.js
@@ -1,5 +1,5 @@
import test from 'ava';
import verify from '../lib/verify';
const test = require('ava');
const verify = require('../lib/verify');

test('Throw SemanticReleaseError if "assets" option is not a String or false or an Array of Objects', t => {
const assets = true;
Expand Down

0 comments on commit 3c1eb83

Please sign in to comment.