@@ -18,10 +18,8 @@ type CloneResult = {
1818 strategy : Action [ 'pullAuthStrategy' ] ;
1919} ;
2020
21- const ensureDirectory = ( targetPath : string ) => {
22- if ( ! fs . existsSync ( targetPath ) ) {
23- fs . mkdirSync ( targetPath , { recursive : true , mode : 0o755 } ) ;
24- }
21+ const ensureDirectory = async ( targetPath : string ) => {
22+ await fs . promises . mkdir ( targetPath , { recursive : true , mode : 0o755 } ) ;
2523} ;
2624
2725const decodeBasicAuth = ( authHeader ?: string ) : BasicCredentials | null => {
@@ -53,15 +51,7 @@ const buildSSHCloneUrl = (remoteUrl: string): string => {
5351} ;
5452
5553const cleanupTempDir = async ( tempDir : string ) => {
56- try {
57- await fs . promises . rm ( tempDir , { recursive : true , force : true } ) ;
58- } catch {
59- try {
60- await fs . promises . rmdir ( tempDir , { recursive : true } ) ;
61- } catch ( _ ) {
62- // ignore cleanup errors
63- }
64- }
54+ await fs . promises . rm ( tempDir , { recursive : true , force : true } ) ;
6555} ;
6656
6757const cloneWithHTTPS = async (
@@ -75,12 +65,9 @@ const cloneWithHTTPS = async (
7565 dir : `${ action . proxyGitPath } /${ action . repoName } ` ,
7666 singleBranch : true ,
7767 depth : 1 ,
68+ onAuth : credentials ? ( ) => credentials : undefined ,
7869 } ;
7970
80- if ( credentials ) {
81- cloneOptions . onAuth = ( ) => credentials ;
82- }
83-
8471 await git . clone ( cloneOptions ) ;
8572} ;
8673
@@ -165,16 +152,8 @@ const exec = async (req: any, action: Action): Promise<Action> => {
165152 try {
166153 action . proxyGitPath = `${ dir } /${ action . id } ` ;
167154
168- if ( ! fs . existsSync ( dir ) ) {
169- fs . mkdirSync ( dir ) ;
170- }
171-
172- if ( ! fs . existsSync ( action . proxyGitPath ) ) {
173- step . log ( `Creating folder ${ action . proxyGitPath } ` ) ;
174- fs . mkdirSync ( action . proxyGitPath , { recursive : true , mode : 0o755 } ) ;
175- }
176-
177- ensureDirectory ( action . proxyGitPath ) ;
155+ await ensureDirectory ( dir ) ;
156+ await ensureDirectory ( action . proxyGitPath ) ;
178157
179158 let result : CloneResult ;
180159
@@ -207,5 +186,4 @@ const exec = async (req: any, action: Action): Promise<Action> => {
207186} ;
208187
209188exec . displayName = 'pullRemote.exec' ;
210-
211189export { exec } ;
0 commit comments