|
1 | 1 | import { git, silentGit } from './process';
|
2 | 2 |
|
3 |
| -export function gitClean() { |
| 3 | +export async function gitClean(): Promise<void> { |
4 | 4 | console.log(' Cleaning git...');
|
5 |
| - return silentGit('clean', '-df') |
6 |
| - .then(() => silentGit('reset', '--hard')) |
7 |
| - .then(() => { |
8 |
| - // Checkout missing files |
9 |
| - return silentGit('status', '--porcelain') |
10 |
| - .then(({ stdout }) => |
11 |
| - stdout |
12 |
| - .split(/[\n\r]+/g) |
13 |
| - .filter((line) => line.match(/^ D/)) |
14 |
| - .map((line) => line.replace(/^\s*\S+\s+/, '')), |
15 |
| - ) |
16 |
| - .then((files) => silentGit('checkout', ...files)); |
17 |
| - }) |
18 |
| - .then(() => expectGitToBeClean()); |
| 5 | + |
| 6 | + await silentGit('clean', '-df'); |
| 7 | + await silentGit('reset', '--hard'); |
| 8 | + |
| 9 | + // Checkout missing files |
| 10 | + const { stdout } = await silentGit('status', '--porcelain'); |
| 11 | + const files = stdout |
| 12 | + .split(/[\n\r]+/g) |
| 13 | + .filter((line) => line.match(/^ D/)) |
| 14 | + .map((line) => line.replace(/^\s*\S+\s+/, '')); |
| 15 | + |
| 16 | + await silentGit('checkout', ...files); |
| 17 | + await expectGitToBeClean(); |
19 | 18 | }
|
20 | 19 |
|
21 |
| -export function expectGitToBeClean() { |
22 |
| - return silentGit('status', '--porcelain').then(({ stdout }) => { |
23 |
| - if (stdout != '') { |
24 |
| - throw new Error('Git repo is not clean...\n' + stdout); |
25 |
| - } |
26 |
| - }); |
| 20 | +export async function expectGitToBeClean(): Promise<void> { |
| 21 | + const { stdout } = await silentGit('status', '--porcelain'); |
| 22 | + if (stdout != '') { |
| 23 | + throw new Error('Git repo is not clean...\n' + stdout); |
| 24 | + } |
27 | 25 | }
|
28 | 26 |
|
29 |
| -export function gitCommit(message: string) { |
30 |
| - return git('add', '-A') |
31 |
| - .then(() => silentGit('status', '--porcelain')) |
32 |
| - .then(({ stdout }) => { |
33 |
| - if (stdout != '') { |
34 |
| - return git('commit', '-am', message); |
35 |
| - } |
36 |
| - }); |
| 27 | +export async function gitCommit(message: string): Promise<void> { |
| 28 | + await git('add', '-A'); |
| 29 | + const { stdout } = await silentGit('status', '--porcelain'); |
| 30 | + if (stdout != '') { |
| 31 | + await git('commit', '-am', message); |
| 32 | + } |
37 | 33 | }
|
0 commit comments