convert functions to async

This commit is contained in:
Tejas Srikanth 2023-03-30 11:58:24 -04:00
parent 4996ec8140
commit df0e13e2c1
1 changed files with 55 additions and 35 deletions

View File

@ -34,45 +34,65 @@ export async function cloneRepo(httpAddr: string) {
return tmpFolderPath;
}
export function pushRepo(repoPath) {
exec("git -C " + repoPath + " push", (error, stdout, stderr) => {
throwIfError(error);
console.log(`stdout: ${stderr}`);
});
}
export function commitRepo(repoPath) {
exec("git -C " + repoPath + " add .", (error, stdout, stderr) => {
throwIfError(error);
exec(
"git -C " + repoPath + ' commit -m "generic commit message"',
(error, stdout, stderr) => {
throwIfError(error);
console.log(`stdout: ${stderr}`);
}
export async function pushRepo(repoPath: string) {
try{
const stdOut = execSync(`git -C ${repoPath} push`).toString();
console.log(`Push output is: ${stdOut}`);
} catch (error){
console.error(
`Failed to push to repo: ${error.status}
${error.message}
${error.stderr.toString()}
${error.stdout.toString()}`
);
});
throw error.message;
}
return repoPath;
}
function createAndPublishNewBranch(repoPath) {
var id = uuid();
exec(
"git -C " +
repoPath +
" checkout -b " +
id +
" && git -C " +
repoPath +
" push -u origin " +
id,
(error, stdout, stderr) => {
throwIfError(error);
console.log(`stdout: ${stderr}`);
return id;
}
);
export async function commitRepo(repoPath) {
try{
const stdOut = execSync(`git -C ${repoPath} commit -m \'event commit\'`);
console.log(`Push output is: ${stdOut}`);
} catch (error){
console.error(
`Failed to push to repo: ${error.status}
${error.message}
${error.stderr.toString()}
${error.stdout.toString()}`
);
throw error.message;
}
return repoPath;
}
export async function createAndPublishNewBranch(repoPath) {
try{
var id = uuid();
execSync(
`git -C ${repoPath} checkout -b ${id} && git -C ${repoPath} push -u origin`
);
} catch (error){
console.error(
`Failed to push to repo: ${error.status}
${error.message}
${error.stderr.toString()}
${error.stdout.toString()}`
);
throw error.message;
}
}
export function removeRepo(repoPath) {
exec("rm -r " + repoPath);
try{
execSync(`rm -r ${repoPath}`);
} catch (error){
`Failed to push to repo: ${error.status}
${error.message}
${error.stderr.toString()}
${error.stdout.toString()}`
throw error.message;
}
}