Skip to content

Commit

Permalink
fix: Throw original error
Browse files Browse the repository at this point in the history
  • Loading branch information
finom committed Jun 6, 2017
1 parent 4b0b4e1 commit d797580
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions index.js
Expand Up @@ -38,13 +38,8 @@ for (const [field, isRequired] of entries(fields)) {

console.log('Starting deploy to Git...');
console.log(`Cloning the repository to "${config.folder}" folder...`);
try {
execSync(`git clone -b ${config.branch} ${config.repository} ${config.folder} 2>&1`, { cwd });
} catch (e) {
console.error('Failed to clone. An original error is thrown below.');
throw Error(e);
}

execSync(`git clone -b ${config.branch} ${config.repository} ${config.folder}`, { cwd });

console.log(`Starting script "${config.script}"...`);
console.log(execSync(`${config.script}`, { cwd }).toString('utf-8'));
Expand All @@ -55,33 +50,23 @@ execSync(`
git config user.email "${config.user_email}" &&
git config user.name "${config.user_name}" &&
git add . &&
git commit --allow-empty -m "${config.commit}" 2>&1
git commit --allow-empty -m "${config.commit}"
`, { cwd });

if (config.beforePushScript) {
console.log('Running beforePushScript...');

try {
execSync(`
cd ${config.folder} &&
${config.beforePushScript}
`, { cwd });
} catch (e) {
console.error('Failed to run beforePushScript. An original error is thrown below.');
throw Error(e);
}
}

console.log('Pushing...');
try {
execSync(`
cd ${config.folder} &&
git push --tags ${config.repository} ${config.branch} 2>&1
${config.beforePushScript}
`, { cwd });
} catch (e) {
console.error('Failed to push. An original error is thrown below.');
throw Error(e);
}

console.log('Pushing...');

execSync(`
cd ${config.folder} &&
git push --tags ${config.repository} ${config.branch}
`, { cwd });

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

0 comments on commit d797580

Please sign in to comment.