File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,18 @@ const withMediaButtonModule = (config) => {
481481
482482 // Check if MediaButtonPackage is already imported/added
483483 if ( ! mainApplication . contents . includes ( 'MediaButtonPackage' ) ) {
484+ // Get the package name from the first line of the file
485+ const packageMatch = mainApplication . contents . match ( / ^ p a c k a g e \s + ( [ ^ \s ] + ) / ) ;
486+ const packageName = packageMatch ? packageMatch [ 1 ] : 'com.resgrid.unit' ;
487+
488+ // Add import statement for MediaButtonPackage after the package declaration
489+ const importStatement = `import ${ packageName } .MediaButtonPackage` ;
490+ if ( ! mainApplication . contents . includes ( importStatement ) ) {
491+ // Add import after the package declaration line
492+ mainApplication . contents = mainApplication . contents . replace ( / ^ ( p a c k a g e \s + [ ^ \n ] + \n ) / , `$1${ importStatement } \n` ) ;
493+ console . log ( '[withMediaButtonModule] Added MediaButtonPackage import' ) ;
494+ }
495+
484496 // Add the package to getPackages()
485497 // Find the packages list and add our package
486498 const packagesPattern = / v a l p a c k a g e s = P a c k a g e L i s t \( t h i s \) \. p a c k a g e s ( \. t o M u t a b l e L i s t \( \) ) ? / ;
You can’t perform that action at this time.
0 commit comments