Skip to content

Commit a0398ba

Browse files
committed
fix: cd before push
1 parent 6b0f1e0 commit a0398ba

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ for (const field of fields) {
2626

2727
console.log('Deploying to git...');
2828
console.log(`Cloning to ${config.folder}...`);
29-
execSync(`git clone -b ${config.branch} ${config.repository} ${config.folder} 2>&1`, { cwd });
29+
try {
30+
execSync(`git clone -b ${config.branch} ${config.repository} ${config.folder} 2>&1`, { cwd });
31+
} catch(e) {
32+
throw Error('Failed to clone.');
33+
}
34+
3035

3136
console.log(`Starting script ${config.script}...`);
3237
console.log(execSync(`${config.script}`, { cwd }).toString('utf-8'));
@@ -41,6 +46,14 @@ execSync(`
4146
`, { cwd });
4247

4348
console.log('Pushing...');
44-
execSync(`git push ${config.repository} ${config.branch}`, { cwd });
49+
try {
50+
execSync(`
51+
cd ${config.folder} &&
52+
git push ${config.repository} ${config.branch} 2>&1
53+
`, { cwd });
54+
} catch(e) {
55+
throw Error('Failed to push.')
56+
}
57+
4558

4659
console.log('Deploying to git is finished.');

0 commit comments

Comments
 (0)