@@ -261,7 +261,7 @@ function unzip(src, dest) {
261261 return execShellCommand ( `unzip "${ src } " -d "${ dest } "` ) ;
262262}
263263
264- async function getOssFiles ( folderPath , skipOssReadme ) {
264+ async function getOssFiles ( folderPath , isOssReadmeRequired ) {
265265 if ( ! folderPath || typeof folderPath !== "string" ) {
266266 throw new TypeError ( `Invalid folderPath: ${ folderPath } ` ) ;
267267 }
@@ -273,17 +273,17 @@ async function getOssFiles(folderPath, skipOssReadme) {
273273 throw new Error ( `License file not found at expected location: ${ licenseFile } ` ) ;
274274 }
275275
276- if ( skipOssReadme ) {
277- return [ { src : licenseFile , dest : basename ( licenseFile ) } ] ;
278- }
279-
280276 const readmeossPattern = "*__*__READMEOSS_*.html" ;
281277 const readmeossFiles = globSync ( readmeossPattern , { cwd : folderPath , absolute : true , ignore : "**/.*/**" } ) ;
282278
283- if ( readmeossFiles . length === 0 ) {
279+ if ( isOssReadmeRequired && readmeossFiles . length === 0 ) {
284280 throw new Error ( `No OSS README file found in ${ folderPath } matching ${ readmeossPattern } ` ) ;
285281 }
286282
283+ if ( readmeossFiles . length === 0 ) {
284+ return [ { src : licenseFile , dest : basename ( licenseFile ) } ] ;
285+ }
286+
287287 const ossReadmeFile = readmeossFiles [ 0 ] ;
288288
289289 return [
@@ -292,13 +292,13 @@ async function getOssFiles(folderPath, skipOssReadme) {
292292 ] ;
293293}
294294
295- async function copyFilesToMpk ( filesToAdd , mpkOutput , moduleName ) {
295+ async function copyFilesToMpk ( files , mpkOutput , moduleName ) {
296296 const projectPath = mpkOutput . replace ( ".mpk" , "" ) ;
297297 // Unzip the mpk
298298 await unzip ( mpkOutput , projectPath ) ;
299299 await rm ( mpkOutput , { recursive : true , force : true } ) ;
300300 // Add additional files to the MPK
301- for await ( const file of filesToAdd ) {
301+ for await ( const file of files ) {
302302 await copyFile ( file . src , join ( projectPath , file . dest ) ) ;
303303 }
304304 // Re-zip and rename
@@ -307,7 +307,7 @@ async function copyFilesToMpk(filesToAdd, mpkOutput, moduleName) {
307307}
308308
309309// Unzip the module, copy the widget and update package.xml
310- async function exportModuleWithWidgets ( moduleName , mpkOutput , widgetsFolders , filesToAdd ) {
310+ async function exportModuleWithWidgets ( moduleName , mpkOutput , widgetsFolders , additionalFiles ) {
311311 console . log ( `Adding ${ widgetsFolders . length } widgets to module ${ moduleName } ` ) ;
312312 const projectPath = mpkOutput . replace ( ".mpk" , "" ) ;
313313 const packageXmlFile = join ( projectPath , "package.xml" ) ;
@@ -345,7 +345,7 @@ async function exportModuleWithWidgets(moduleName, mpkOutput, widgetsFolders, fi
345345 throw new Error ( `Including widgets in module failed. package.xml of widget/module ${ moduleName } not found` ) ;
346346 }
347347 // Add additional files to the MPK
348- for await ( const file of filesToAdd ) {
348+ for await ( const file of additionalFiles ) {
349349 await copyFile ( file . src , join ( projectPath , file . dest ) ) ;
350350 }
351351 // Re-zip and rename
0 commit comments