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

refactor: Enhance log #444

Merged
merged 1 commit into from
Aug 9, 2020
Merged
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
33 changes: 14 additions & 19 deletions src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export async function deleteExcludedAssets(destDir: string, excludeAssets: strin
})();
const globber = await glob.create(excludedAssetPaths.join('\n'));
for await (const asset of globber.globGenerator()) {
io.rmRF(asset);
core.info(`[INFO] delete ${asset}`);
io.rmRF(asset);
}
return;
}
Expand All @@ -51,8 +51,8 @@ export async function copyAssets(
if (fs.existsSync(destPath) === false) {
await createDir(destPath);
}
await io.cp(filePublishPath, fileDestPath, copyOpts);
core.info(`[INFO] copy ${file}`);
await io.cp(filePublishPath, fileDestPath, copyOpts);
}

await deleteExcludedAssets(destDir, excludeAssets);
Expand All @@ -79,6 +79,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
if (inps.ForceOrphan) {
await createDir(destDir);
core.info(`[INFO] chdir ${workDir}`);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
Expand All @@ -105,34 +106,28 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
);
if (result.exitcode === 0) {
await createDir(destDir);
process.chdir(destDir);

if (inps.DestinationDir !== '') {
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
core.info(`[INFO] clean up ${destDir}`);
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}

if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
core.info(`[INFO] clean up ${destDir}`);
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}
core.info(`[INFO] clean up ${destDir}`);
core.info(`[INFO] chdir ${destDir}`);
process.chdir(destDir);
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}

await copyAssets(publishDir, destDir, inps.ExcludeAssets);
core.info(`[INFO] chdir ${workDir}`);
process.chdir(workDir);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
return;
} else {
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
}
} catch (e) {
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
core.info(e.message);
core.info(`[INFO] ${e.message}`);
await createDir(destDir);
core.info(`[INFO] chdir ${workDir}`);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
Expand Down