File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change 1
1
fs = require (' fs' )
2
2
path = require (' path' )
3
+ findsRoot = require (' find-root-package' )
3
4
4
5
module .exports =
5
6
initialize : (dir = process .cwd ()) ->
6
- return unless (topDir = findTopPackageJson (dir)) && (topDir != dir)
7
+ topDir = findsRoot .findTopPackageJson (dir)
8
+ return unless isInstalledAsDependency (dir, topDir)
7
9
return if fs .existsSync (dest = path .join (topDir, ' .bowerrc' ))
8
10
console .log (" Writing a default '.bowerrc' file into '#{ topDir} '" )
9
11
fs .writeFileSync dest, """
@@ -13,16 +15,7 @@ module.exports =
13
15
14
16
"""
15
17
16
- findTopPackageJson = (dir ) ->
17
- current = path .resolve (dir)
18
- grandparent = path .resolve (dir, " .." , " .." )
19
- if current == grandparent || ! hasPackageJson (grandparent)
20
- if hasPackageJson (current)
21
- current
22
- else
23
- null
24
- else
25
- findTopPackageJson (grandparent)
18
+ isInstalledAsDependency = (dir , topDir ) ->
19
+ topDir? && topDir != dir
20
+
26
21
27
- hasPackageJson = (dir ) ->
28
- fs .existsSync (path .join (dir, " package.json" ))
Original file line number Diff line number Diff line change 22
22
},
23
23
"dependencies" : {
24
24
"grunt-bower-task" : " ~0.4.0" ,
25
- "coffee-script" : " ~1.6.3"
25
+ "coffee-script" : " ~1.6.3" ,
26
+ "find-root-package" : " 0.0.1"
26
27
},
27
28
"peerDependencies" : {
28
- "lineman" : " >= 0.19.0"
29
+ "grunt" : " ~0.4.1" ,
30
+ "lineman" : " >= 0.27.0"
29
31
},
30
32
"devDependencies" : {
31
- "grunt" : " ^0.4.4" ,
32
33
"grunt-release" : " ^0.7.0"
33
34
},
34
35
"licenses" : [
You can’t perform that action at this time.
0 commit comments