@@ -6,6 +6,7 @@ import path from 'path';
6
6
import fs from 'fs' ;
7
7
import { Inputs , CmdResult } from './interfaces' ;
8
8
import { createDir } from './utils' ;
9
+ import { cp } from 'shelljs' ;
9
10
10
11
export async function createBranchForce ( branch : string ) : Promise < void > {
11
12
await exec . exec ( 'git' , [ 'init' ] ) ;
@@ -37,24 +38,21 @@ export async function copyAssets(
37
38
excludeAssets : string
38
39
) : Promise < void > {
39
40
core . info ( `[INFO] prepare publishing assets` ) ;
40
- const copyOpts = { recursive : true , force : true } ;
41
- const files = fs . readdirSync ( publishDir ) ;
42
- core . debug ( `${ files } ` ) ;
43
- for await ( const file of files ) {
44
- if ( file === '.git' ) {
45
- core . info ( `[INFO] skip ${ file } ` ) ;
46
- continue ;
47
- }
48
- const filePublishPath = path . join ( publishDir , file ) ;
49
- const fileDestPath = path . join ( destDir , file ) ;
50
- const destPath = path . dirname ( fileDestPath ) ;
51
- if ( fs . existsSync ( destPath ) === false ) {
52
- await createDir ( destPath ) ;
53
- }
54
- core . info ( `[INFO] copy ${ file } ` ) ;
55
- await io . cp ( filePublishPath , fileDestPath , copyOpts ) ;
41
+
42
+ if ( fs . existsSync ( destDir ) === false ) {
43
+ core . info ( `[INFO] create ${ destDir } ` ) ;
44
+ await createDir ( destDir ) ;
56
45
}
57
46
47
+ const dotGitPath = path . join ( publishDir , '.git' ) ;
48
+ if ( fs . existsSync ( dotGitPath ) ) {
49
+ core . info ( `[INFO] delete .git` ) ;
50
+ io . rmRF ( dotGitPath ) ;
51
+ }
52
+
53
+ core . info ( `[INFO] copy ${ publishDir } to ${ destDir } ` ) ;
54
+ cp ( '-RfL' , [ `${ publishDir } /*` ] , destDir ) ;
55
+
58
56
await deleteExcludedAssets ( destDir , excludeAssets ) ;
59
57
60
58
return ;
0 commit comments