Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
fix(execa): handled the execa response properly
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Dec 17, 2020
1 parent a4a690f commit 93a7a41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/husky-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ suite('husky', () => {
core.fileExists.withArgs(`${projectRoot}/.huskyrc.json`).resolves(true);
execa.default
.withArgs('npm', ['ls', 'husky', '--json'])
.resolves(JSON.stringify({dependencies: {husky: {version: '5.0.0'}}}));
.resolves({stdout: JSON.stringify({dependencies: {husky: {version: '5.0.0'}}})});

assert.deepEqual(
await liftHusky({projectRoot}),
Expand All @@ -34,7 +34,7 @@ suite('husky', () => {
core.fileExists.withArgs(`${projectRoot}/.huskyrc.json`).resolves(true);
execa.default
.withArgs('npm', ['ls', 'husky', '--json'])
.resolves(JSON.stringify({dependencies: {husky: {version: '5.0.1'}}}));
.resolves({stdout: JSON.stringify({dependencies: {husky: {version: '5.0.1'}}})});

assert.deepEqual(
await liftHusky({projectRoot}),
Expand All @@ -46,22 +46,22 @@ suite('husky', () => {
core.fileExists.withArgs(`${projectRoot}/.huskyrc.json`).resolves(true);
execa.default
.withArgs('npm', ['ls', 'husky', '--json'])
.resolves(JSON.stringify({dependencies: {husky: {version: '4.5.6'}}}));
.resolves({stdout: JSON.stringify({dependencies: {husky: {version: '4.5.6'}}})});

assert.deepEqual(await liftHusky({projectRoot}), {});
});

test('that no next-step is listed when v5 is installed and v5 config exists', async () => {
execa.default
.withArgs('npm', ['ls', 'husky', '--json'])
.resolves(JSON.stringify({dependencies: {husky: {version: '5.6.7'}}}));
.resolves({stdout: JSON.stringify({dependencies: {husky: {version: '5.6.7'}}})});
core.fileExists.resolves(false);

assert.deepEqual(await liftHusky({projectRoot}), {});
});

test('that not having husky installed does not result in an error', async () => {
execa.default.withArgs('npm', ['ls', 'husky', '--json']).resolves(JSON.stringify({}));
execa.default.withArgs('npm', ['ls', 'husky', '--json']).resolves({stdout: JSON.stringify({})});
core.fileExists.resolves(any.boolean());

await liftHusky({projectRoot});
Expand Down
2 changes: 1 addition & 1 deletion src/husky.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {fileExists} from '@form8ion/core';
import execa from '../thirdparty-wrappers/execa';

export default async function ({projectRoot}) {
const [huskyVersionDetails, huskyV4ConfigExists] = await Promise.all([
const [{stdout: huskyVersionDetails}, huskyV4ConfigExists] = await Promise.all([
await execa('npm', ['ls', 'husky', '--json']),
await fileExists(`${projectRoot}/.huskyrc.json`)
]);
Expand Down
6 changes: 3 additions & 3 deletions test/integration/features/step_definitions/husky-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import {assert} from 'chai';
Given('husky v5 is installed', async function () {
td
.when(this.execa('npm', ['ls', 'husky', '--json']))
.thenResolve(JSON.stringify({dependencies: {husky: {version: '5.0.0'}}}));
.thenResolve({stdout: JSON.stringify({dependencies: {husky: {version: '5.0.0'}}})});
});

Given('husky v4 is installed', async function () {
td
.when(this.execa('npm', ['ls', 'husky', '--json']))
.thenResolve(JSON.stringify({dependencies: {husky: {version: '4.5.6'}}}));
.thenResolve({stdout: JSON.stringify({dependencies: {husky: {version: '4.5.6'}}})});
});

Given('husky is not installed', async function () {
td.when(this.execa('npm', ['ls', 'husky', '--json'])).thenResolve(JSON.stringify({}));
td.when(this.execa('npm', ['ls', 'husky', '--json'])).thenResolve({stdout: JSON.stringify({})});
});

Given('husky config is in v4 format', async function () {
Expand Down

0 comments on commit 93a7a41

Please sign in to comment.