fix: copyAssets (#512)

* deps: Add shelljs @types/shelljs
* fix: copyAssets

use shelljs.cp instead of actions/core/io/cp (io.cp)

- https://github.com/shelljs/shelljs
This commit is contained in:
Shohei Ueda
2020-10-14 18:13:17 +09:00
committed by GitHub
parent 46b269eb77
commit 725f7db867
3 changed files with 45 additions and 32 deletions

View File

@@ -6,6 +6,7 @@ import path from 'path';
import fs from 'fs';
import {Inputs, CmdResult} from './interfaces';
import {createDir} from './utils';
import {cp} from 'shelljs';
export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']);
@@ -37,24 +38,21 @@ export async function copyAssets(
excludeAssets: string
): Promise<void> {
core.info(`[INFO] prepare publishing assets`);
const copyOpts = {recursive: true, force: true};
const files = fs.readdirSync(publishDir);
core.debug(`${files}`);
for await (const file of files) {
if (file === '.git') {
core.info(`[INFO] skip ${file}`);
continue;
}
const filePublishPath = path.join(publishDir, file);
const fileDestPath = path.join(destDir, file);
const destPath = path.dirname(fileDestPath);
if (fs.existsSync(destPath) === false) {
await createDir(destPath);
}
core.info(`[INFO] copy ${file}`);
await io.cp(filePublishPath, fileDestPath, copyOpts);
if (fs.existsSync(destDir) === false) {
core.info(`[INFO] create ${destDir}`);
await createDir(destDir);
}
const dotGitPath = path.join(publishDir, '.git');
if (fs.existsSync(dotGitPath)) {
core.info(`[INFO] delete .git`);
io.rmRF(dotGitPath);
}
core.info(`[INFO] copy ${publishDir} to ${destDir}`);
cp('-RfL', [`${publishDir}/*`], destDir);
await deleteExcludedAssets(destDir, excludeAssets);
return;