Skip to content

Commit f3f4fa0

Browse files
committed
Add logic, to rename extracted ui5 directrory to 'resources', if downloaded content is wrapped in a directory.
1 parent 49139a0 commit f3f4fa0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ function ui5Download(sDownloadURL, sDownloadPath, sUI5Version, oOptions = {}) {
9494
// extracts everything
9595
zip.extractAllTo(sTargetPath, overwrite)
9696

97+
// if sap-ui-core.js is not located in extracted root,
98+
// we will rename the download directory to 'resources'
99+
if (!fs.existsSync(`${sTargetPath}/sap-ui-core.js`)) {
100+
// read all extracted files in current directory
101+
const aFiles = fs.readdirSync(sTargetPath)
102+
aFiles.forEach(sFileName => {
103+
if (
104+
fs.statSync(`${sTargetPath}/${sFileName}`).isDirectory()
105+
) {
106+
// rename download folder in root
107+
try {
108+
fs.renameSync(
109+
`${sTargetPath}/${sFileName}`,
110+
`${sTargetPath}/resources`
111+
)
112+
} catch (e) {
113+
// skip renaming
114+
}
115+
}
116+
})
117+
}
118+
97119
// resolve promise
98120
return resolve(`UI5 download successful: ${sTargetPath}`)
99121
}

0 commit comments

Comments
 (0)