@@ -29,6 +29,7 @@ function prepPackage(pkgName) {
2929 let files = { } ;
3030 files . sources = path . resolve ( paths . pkgsrc , "sources.json" ) ;
3131 files . pkgfile = path . resolve ( paths . pkgsrc , "package.json" ) ;
32+ files . bowerfile = path . resolve ( paths . pkgsrc , "bower.json" ) ;
3233 files . tsconfig = path . resolve ( paths . pkgsrc , "tsconfig.json" ) ;
3334 files . webpack = path . resolve ( paths . pkgsrc , "webpack.config.js" ) ;
3435
@@ -66,6 +67,21 @@ function prepPackage(pkgName) {
6667 fs . writeFileSync ( packageJsonDest , asJson ( packageJson ) ) ;
6768 }
6869
70+ // If the package definition contains a bower.json, merge it with specific fields from the package.json in
71+ // the project root, and write it to the package build dir
72+ if ( test ( '-f' , files . bowerfile ) ) {
73+ let bowerJsonDest = `${ paths . build } /bower.json` ;
74+ let pkg = require ( '../package.json' ) ;
75+
76+ echo ( `Merging ${ files . bowerfile } with ${ paths . basedir } /package.json ...` ) ;
77+ echo ( `... and writing to ${ bowerJsonDest } ` ) ;
78+
79+ let packageJson = JSON . parse ( fs . readFileSync ( files . bowerfile , 'utf8' ) ) ;
80+ packageJson . version = pkg . version ;
81+ packageJson . homepage = pkg . homepage ;
82+ fs . writeFileSync ( bowerJsonDest , asJson ( packageJson ) ) ;
83+ }
84+
6985 echo ( `Copying typescript sources to ${ paths . srcCopy } ` ) ;
7086 cp ( '-R' , `${ paths . basedir } /src/` , paths . srcCopy ) ;
7187 console . log ( "Excludes: " + sources . excludes ) ;
@@ -83,7 +99,7 @@ function prepPackage(pkgName) {
8399
84100 // Copy any of these files from the packages dir
85101 // Override any baseFiles with the copy from the package dir.
86- let pkgFiles = [ 'bower.json' , ' .gitignore', '.npmignore' ] ;
102+ let pkgFiles = [ '.gitignore' , '.npmignore' ] ;
87103 baseFiles . concat ( pkgFiles ) . filter ( file => test ( '-f' , `${ paths . pkgsrc } /${ file } ` ) )
88104 . forEach ( file => cp ( `${ paths . pkgsrc } /${ file } ` , paths . build ) ) ;
89105
0 commit comments