File tree Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Original file line number Diff line number Diff line change 3
3
var fs = require ( 'fs' ) ,
4
4
path = require ( 'path' ) ,
5
5
chalk = require ( 'chalk' ) ,
6
- doxdox = require ( '..' ) ;
6
+ doxdox = require ( '..' ) ,
7
+ utils = require ( '../lib/utils' ) ;
7
8
8
9
var config = {
9
10
title : '' ,
@@ -95,35 +96,23 @@ while (args.length) {
95
96
96
97
}
97
98
98
- var stat ;
99
+ if ( ! pkg ) {
99
100
100
- if ( ! pkg && fs . existsSync ( input ) ) {
101
-
102
- stat = fs . statSync ( input ) ;
103
-
104
- if ( stat . isDirectory ( ) ) {
105
-
106
- pkg = path . normalize ( path . resolve ( input ) + '/package.json' ) ;
107
-
108
- } else if ( stat . isFile ( ) ) {
109
-
110
- pkg = path . normalize ( path . resolve ( path . dirname ( input ) ) + '/package.json' ) ;
111
-
112
- }
101
+ pkg = utils . findPackage ( input ) ;
113
102
114
103
}
115
104
116
105
if ( fs . existsSync ( pkg ) ) {
117
106
118
107
pkg = require ( pkg ) ;
119
108
120
- if ( pkg . name && ! config . title ) {
109
+ if ( ! config . title && pkg . name ) {
121
110
122
111
config . title = pkg . name ;
123
112
124
113
}
125
114
126
- if ( pkg . description && ! config . description ) {
115
+ if ( ! config . description && pkg . description ) {
127
116
128
117
config . description = pkg . description ;
129
118
Original file line number Diff line number Diff line change 1
1
var fs = require ( 'fs' ) ,
2
2
path = require ( 'path' ) ;
3
3
4
+ module . exports . findPackage = function ( input ) {
5
+
6
+ var stat ,
7
+ pkg ;
8
+
9
+ if ( fs . existsSync ( input ) ) {
10
+
11
+ stat = fs . statSync ( input ) ;
12
+
13
+ if ( stat . isDirectory ( ) ) {
14
+
15
+ pkg = path . normalize ( path . resolve ( input ) + '/package.json' ) ;
16
+
17
+ } else if ( stat . isFile ( ) ) {
18
+
19
+ pkg = path . normalize ( path . resolve ( path . dirname ( input ) ) + '/package.json' ) ;
20
+
21
+ }
22
+
23
+ }
24
+
25
+ return pkg ;
26
+
27
+ } ;
28
+
4
29
module . exports . formatStringForUID = function ( content ) {
5
30
6
31
content = String ( content ) . toLowerCase ( ) ;
You can’t perform that action at this time.
0 commit comments