File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed
Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -197,12 +197,20 @@ public function getModulePaths($module, $minified = false)
197197
198198 /**
199199 * Returns path to bower.json for specified module
200+ * If usePackageJson option is set to true and bower.json is not readable, returns path to package.json
200201 * @param string $module
201202 * @return string
202203 */
203204 public function getModuleBowerConfigFilePath ($ module )
204205 {
205- return $ this ->getPathBuilder ()->getOsPath ($ this ->getBowerFolder (), $ module , 'bower.json ' );
206+ $ path = $ this ->getPathBuilder ()->getOsPath ($ this ->getBowerFolder (), $ module , 'bower.json ' );
207+ if (!is_readable ($ path ) && $ this ->getConfig ()->getUsePackageJson ()){
208+ $ path = $ this ->getPathBuilder ()->getOsPath ($ this ->getBowerFolder (), $ module , 'package.json ' );
209+ }
210+ if (!is_readable ($ path )){
211+ throw new \RuntimeException ('Failed to access configuration for " ' .$ module .'". ' );
212+ }
213+ return $ path ;
206214 }
207215
208216 /**
@@ -214,10 +222,6 @@ public function getModuleBowerConfig($module)
214222 {
215223 //TODO add caching
216224 $ filePath = $ this ->getModuleBowerConfigFilePath ($ module );
217- if (!is_readable ($ filePath ))
218- {
219- throw new \RuntimeException ('Failed to access configuration for " ' .$ module .'". ' );
220- }
221225 $ config = file_get_contents ($ filePath );
222226 if ($ config === false )
223227 {
Original file line number Diff line number Diff line change @@ -38,7 +38,12 @@ class Module extends AbstractOptions
3838 * @var bool
3939 */
4040 protected $ debugMode ;
41-
41+ /**
42+ * Set to true if you want to scan for package.json file in addition to bower.json
43+ * @var bool
44+ */
45+ protected $ usePackageJson = false ;
46+
4247 /**
4348 * @param array|Folder $bowerFolder
4449 */
@@ -154,4 +159,12 @@ public function getDebugMode()
154159 {
155160 return (bool ) $ this ->debugMode ;
156161 }
162+
163+ public function getUsePackageJson () {
164+ return (bool ) $ this ->usePackageJson ;
165+ }
166+
167+ public function setUsePackageJson ($ usePackageJson ) {
168+ $ this ->usePackageJson = $ usePackageJson ;
169+ }
157170}
Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ public function __invoke(
7676 {
7777 $ bower = $ this ->getBower ();
7878 $ modules = $ bower ->findDependencies ($ pack ->getModules ());
79+ if ($ place == self ::PLACE_PREPEND ){
80+ $ modules = array_reverse ($ modules );
81+ }
7982 foreach ($ modules as $ moduleName )
8083 {
8184 $ insert ($ pathBuilder ->getDebugWebPath ($ moduleName ));
You can’t perform that action at this time.
0 commit comments