refactor: Enhance log (#444)

This commit is contained in:
Shohei Ueda 2020-08-09 09:48:27 +09:00 committed by GitHub
parent ba912f746b
commit f80024481c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 18 deletions

View File

@ -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;
}
@ -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);
@ -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);
@ -105,34 +106,28 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
);
if (result.exitcode === 0) {
await createDir(destDir);
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
core.info(`[INFO] clean up ${destDir}`);
core.info(`[INFO] chdir ${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', '*']);
}
} 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', '*']);
}
}
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);