Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with newline #4

Closed
wants to merge 9 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
const { execSync } = require('child_process');
const entries = require('object.entries');
const { execSync } = require(`child_process`);
const entries = require(`object.entries`);

const variablePrefix = 'npm_package_config_deployToGit_';
const variablePrefix = `npm_package_config_deployToGit_`;
const fields = {
repository: true,
branch: true,
Expand Down Expand Up @@ -36,37 +36,26 @@ for (const [field, isRequired] of entries(fields)) {
}
}

console.log('Starting deploy to Git...');
console.log(`Starting deploy to Git...`);
console.log(`Cloning the repository to "${config.folder}" folder...`);

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'));
console.log(execSync(`${config.script}`, { cwd }).toString(`utf-8`));

console.log('Configuring and committing...');
execSync(`
cd ${config.folder} &&
git config user.email "${config.user_email}" &&
git config user.name "${config.user_name}" &&
git add . &&
git commit --allow-empty -m "${config.commit}"
`, { cwd });
console.log(`Configuring and committing...`);
execSync(`cd ${config.folder} && git add . && git commit --allow-empty -m "${config.commit}"`, { cwd });

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

execSync(`
cd ${config.folder} &&
${config.beforePushScript}
`, { cwd });
execSync(`cd ${config.folder} && ${config.beforePushScript}`, { cwd });
}

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

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

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