@@ -29,6 +29,7 @@ function prepPackage(pkgName) {
29
29
let files = { } ;
30
30
files . sources = path . resolve ( paths . pkgsrc , "sources.json" ) ;
31
31
files . pkgfile = path . resolve ( paths . pkgsrc , "package.json" ) ;
32
+ files . bowerfile = path . resolve ( paths . pkgsrc , "bower.json" ) ;
32
33
files . tsconfig = path . resolve ( paths . pkgsrc , "tsconfig.json" ) ;
33
34
files . webpack = path . resolve ( paths . pkgsrc , "webpack.config.js" ) ;
34
35
@@ -66,6 +67,21 @@ function prepPackage(pkgName) {
66
67
fs . writeFileSync ( packageJsonDest , asJson ( packageJson ) ) ;
67
68
}
68
69
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
+
69
85
echo ( `Copying typescript sources to ${ paths . srcCopy } ` ) ;
70
86
cp ( '-R' , `${ paths . basedir } /src/` , paths . srcCopy ) ;
71
87
console . log ( "Excludes: " + sources . excludes ) ;
@@ -83,7 +99,7 @@ function prepPackage(pkgName) {
83
99
84
100
// Copy any of these files from the packages dir
85
101
// Override any baseFiles with the copy from the package dir.
86
- let pkgFiles = [ 'bower.json' , ' .gitignore', '.npmignore' ] ;
102
+ let pkgFiles = [ '.gitignore' , '.npmignore' ] ;
87
103
baseFiles . concat ( pkgFiles ) . filter ( file => test ( '-f' , `${ paths . pkgsrc } /${ file } ` ) )
88
104
. forEach ( file => cp ( `${ paths . pkgsrc } /${ file } ` , paths . build ) ) ;
89
105
0 commit comments