@@ -21,6 +21,12 @@ type BowerComponent struct {
21
21
Version string `json:"version"`
22
22
}
23
23
24
+ type BowerConfiguration struct {
25
+ Cwd string `json:"cwd"`
26
+ Directory string `json:"directory"`
27
+ Registry string `json:"registry"`
28
+ }
29
+
24
30
// Fetcher always returns bower for BowerComponent
25
31
func (m BowerComponent ) Fetcher () string {
26
32
return "bower" // TODO: support `git` and etc...
@@ -121,13 +127,30 @@ func (builder *BowerBuilder) Analyze(m module.Module, allowUnresolved bool) ([]m
121
127
return deps , nil
122
128
}
123
129
130
+ // resolveBowerComponentsDirectory resolves a component dir from a `.bowerrc` file, falling back to `bower_components`
131
+ func resolveBowerComponentsDirectory (dir string ) string {
132
+ bowerConfigPath := filepath .Join (dir , ".bowerrc" )
133
+ bowerComponentsPath := filepath .Join (dir , "bower_components" )
134
+
135
+ if bowerConfigExists , _ := hasFile (bowerConfigPath ); bowerConfigExists {
136
+ var bowerConfiguration BowerConfiguration
137
+ parseLogged (bowerLogger , bowerConfigPath , & bowerConfiguration )
138
+
139
+ if bowerConfiguration .Directory != "" {
140
+ bowerComponentsPath = bowerConfiguration .Directory
141
+ }
142
+ }
143
+
144
+ return bowerComponentsPath
145
+ }
146
+
124
147
// IsBuilt checks for the existence of `$PROJECT/bower_components`
125
148
func (builder * BowerBuilder ) IsBuilt (m module.Module , allowUnresolved bool ) (bool , error ) {
126
149
bowerLogger .Debug ("Checking Bower build: %#v %#v" , m , allowUnresolved )
127
150
128
151
// TODO: Check if the installed modules are consistent with what's in the
129
152
// actual manifest.
130
- isBuilt , err := hasFile (m .Dir , "bower_components" )
153
+ isBuilt , err := hasFile (resolveBowerComponentsDirectory ( m .Dir ) )
131
154
if err != nil {
132
155
return false , fmt .Errorf ("could not find Bower dependencies folder: %s" , err .Error ())
133
156
}
0 commit comments