@@ -7,18 +7,29 @@ const inputDirectoryPath = pathDirName(fileURLToPath(import.meta.url));
7
7
const packageFileName = "package.json"
8
8
const scriptFileName = "main.js" ;
9
9
const outputDirectoryPath = pathJoin ( inputDirectoryPath , "../hugoalh.GitHubActionsToolkit/module/nodejs-wrapper" ) ;
10
- async function getDirectoryItem ( directoryPath ) {
10
+ async function getDirectoryItem ( directoryPath , relativeBasePath ) {
11
+ if ( typeof relativeBasePath === "undefined" ) {
12
+ relativeBasePath = directoryPath ;
13
+ }
11
14
try {
12
- return await fsReadDir ( directoryPath , { withFileTypes : true } ) ;
13
- } catch {
15
+ let result = [ ] ;
16
+ for ( let item of await fsReadDir ( directoryPath , { withFileTypes : true } ) ) {
17
+ if ( item . isDirectory ( ) ) {
18
+ result . push ( ...await getDirectoryItem ( pathJoin ( directoryPath , item . name ) , relativeBasePath ) ) ;
19
+ } else {
20
+ result . push ( pathJoin ( directoryPath , item . name ) . slice ( relativeBasePath . length + 1 ) . replace ( / \\ / gu, "/" ) ) ;
21
+ }
22
+ }
23
+ return result ;
24
+ } catch ( error ) {
14
25
return [ ] ;
15
26
}
16
27
}
17
28
18
29
/* Clean up or initialize output directory (need to await in order to prevent race conditions). */
19
30
if ( fsExistsSync ( outputDirectoryPath ) ) {
20
- for ( const outputFile of await getDirectoryItem ( outputDirectoryPath ) ) {
21
- await fsRemove ( pathJoin ( outputDirectoryPath , outputFile . name ) , { recursive : true } ) ;
31
+ for ( let fileName of await getDirectoryItem ( outputDirectoryPath ) ) {
32
+ await fsRemove ( pathJoin ( outputDirectoryPath , fileName ) , { recursive : true } ) ;
22
33
}
23
34
} else {
24
35
await fsMKDir ( outputDirectoryPath , { recursive : true } ) ;
0 commit comments