@@ -12,30 +12,35 @@ import manifestSchema from './modules/manifest.schema.json' with { type: 'json'
1212 * Checks that the given bundle manifest was correctly specified
1313 */
1414export async function getBundleManifest ( manifestFile : string , tabCheck ?: boolean ) : Promise < BundleManifest | undefined > {
15- let rawManifest : string ;
15+ let manifestStr : string ;
1616
1717 try {
18- rawManifest = await fs . readFile ( manifestFile , 'utf-8' ) ;
18+ manifestStr = await fs . readFile ( manifestFile , 'utf-8' ) ;
1919 } catch ( error ) {
2020 if ( isNodeError ( error ) && error . code === 'ENOENT' ) {
2121 return undefined ;
2222 }
2323 throw error ;
2424 }
2525
26- const data = JSON . parse ( rawManifest ) as BundleManifest ;
27- validate ( data , manifestSchema , { throwError : true } ) ;
26+ const rawManifest = JSON . parse ( manifestStr ) as BundleManifest ;
27+ validate ( rawManifest , manifestSchema , { throwError : true } ) ;
28+
29+ const manifest = {
30+ ...rawManifest ,
31+ tabs : ! rawManifest . tabs ? rawManifest . tabs : rawManifest . tabs . map ( each => each . trim ( ) ) ,
32+ } ;
2833
2934 // Make sure that all the tabs specified exist
30- if ( tabCheck && data . tabs ) {
35+ if ( tabCheck && manifest . tabs ) {
3136 const tabsDir = await getTabsDir ( ) ;
32- await Promise . all ( data . tabs . map ( async tabName => {
37+ await Promise . all ( manifest . tabs . map ( async tabName => {
3338 const resolvedTab = await resolveSingleTab ( `${ tabsDir } /${ tabName } ` ) ;
3439 if ( resolvedTab === undefined ) throw new Error ( `Failed to find tab with name '${ tabName } '!` ) ;
3540 } ) ) ;
3641 }
3742
38- return data ;
43+ return manifest ;
3944}
4045
4146/**
0 commit comments