Skip to content

Commit 04d40b5

Browse files
committed
refactor(git.ts): rename someFilesExcludedMessage to showSomeFilesExcludedMessage
feat(git.ts): replace text prompt with outro prompt in showSomeFilesExcludedMessage function feat(git.ts): add support for showing excluded files message in getStagedFiles, getChangedFiles, gitAdd and getDiff functions
1 parent ec2e4c6 commit 04d40b5

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/utils/git.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { execa } from 'execa';
2-
import { spinner, text } from '@clack/prompts';
2+
import { outro, spinner } from '@clack/prompts';
33

44
export const assertGitRepo = async () => {
55
try {
@@ -9,13 +9,12 @@ export const assertGitRepo = async () => {
99
}
1010
};
1111

12-
export const someFilesExcludedMessage = (files: string[]) => {
13-
return text({
14-
message: `Some files are .lock files which are excluded by default as it's too big, commit it yourself, don't waste your api tokens. \n${files
12+
export const showSomeFilesExcludedMessage = (files: string[]) => {
13+
outro(
14+
`Some files are .lock files which are excluded by default as it's too big, commit it yourself, don't waste your api tokens. \n${files
1515
.filter((file) => file.includes('.lock') || file.includes('-lock.'))
16-
.join('\n')
17-
}`
18-
});
16+
.join('\n')}`
17+
);
1918
};
2019

2120
export const getStagedFiles = async (): Promise<string[]> => {
@@ -33,7 +32,7 @@ export const getStagedFiles = async (): Promise<string[]> => {
3332
.filter((file) => file.includes('.lock') || file.includes('-lock.'));
3433

3534
if (excludedFiles.length === files.split('\n').length) {
36-
someFilesExcludedMessage(files.split('\n'));
35+
showSomeFilesExcludedMessage(files.split('\n'));
3736
}
3837

3938
return files.split('\n').sort();
@@ -56,7 +55,7 @@ export const getChangedFiles = async (): Promise<string[]> => {
5655
);
5756

5857
if (files.length !== filesWithoutLocks.length) {
59-
someFilesExcludedMessage(files);
58+
showSomeFilesExcludedMessage(files);
6059
}
6160

6261
return filesWithoutLocks.sort();
@@ -73,7 +72,7 @@ export const gitAdd = async ({ files }: { files: string[] }) => {
7372
gitAddSpinner.stop('Done');
7473

7574
if (filteredFiles.length !== files.length) {
76-
someFilesExcludedMessage(files);
75+
showSomeFilesExcludedMessage(files);
7776
}
7877
};
7978

@@ -83,7 +82,7 @@ export const getDiff = async ({ files }: { files: string[] }) => {
8382
);
8483

8584
if (filesWithoutLocks.length !== files.length) {
86-
someFilesExcludedMessage(files);
85+
showSomeFilesExcludedMessage(files);
8786
}
8887

8988
const { stdout: diff } = await execa('git', [

0 commit comments

Comments
 (0)