Skip to content

Commit 3e15e87

Browse files
committed
Cleanup visual-tests script
1 parent 98e9ff6 commit 3e15e87

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

packages/components/scripts/visual-tests.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ const execa = require('execa');
22
const git = require('simple-git')();
33

44
const hasChanges = async () => {
5-
const result = await git.diffSummary(['master...HEAD']);
6-
if (result.files.length) return true;
7-
return false;
5+
const { files } = await git.diffSummary(['master...HEAD']);
6+
7+
return files.length > 0;
88
};
99

1010
const run = autoAccept => {
1111
const options = ['chromatic:base'];
12-
if (autoAccept) options.push('--auto-accept-changes');
12+
if (autoAccept) {
13+
options.push('--auto-accept-changes');
14+
}
1315

1416
execa('yarn', options).stdout.pipe(process.stdout);
1517
};
@@ -18,12 +20,14 @@ const start = async () => {
1820
const { current: currentBranch } = await git.branch();
1921

2022
if (currentBranch === 'master') {
21-
run(true);
22-
} else {
23-
const changes = await hasChanges();
24-
if (changes) run();
25-
else console.warn('No changes found in branch, skipping visual tests');
23+
return run(true);
2624
}
25+
26+
if (await hasChanges()) {
27+
return run();
28+
}
29+
30+
console.warn('No changes found in branch, skipping visual tests');
2731
};
2832

2933
start();

0 commit comments

Comments
 (0)