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 33var fs = require ( 'fs' ) ,
44 path = require ( 'path' ) ,
55 chalk = require ( 'chalk' ) ,
6- doxdox = require ( '..' ) ;
6+ doxdox = require ( '..' ) ,
7+ utils = require ( '../lib/utils' ) ;
78
89var config = {
910 title : '' ,
@@ -95,35 +96,23 @@ while (args.length) {
9596
9697}
9798
98- var stat ;
99+ if ( ! pkg ) {
99100
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 ) ;
113102
114103}
115104
116105if ( fs . existsSync ( pkg ) ) {
117106
118107 pkg = require ( pkg ) ;
119108
120- if ( pkg . name && ! config . title ) {
109+ if ( ! config . title && pkg . name ) {
121110
122111 config . title = pkg . name ;
123112
124113 }
125114
126- if ( pkg . description && ! config . description ) {
115+ if ( ! config . description && pkg . description ) {
127116
128117 config . description = pkg . description ;
129118
Original file line number Diff line number Diff line change 11var fs = require ( 'fs' ) ,
22 path = require ( 'path' ) ;
33
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+
429module . exports . formatStringForUID = function ( content ) {
530
631 content = String ( content ) . toLowerCase ( ) ;
You can’t perform that action at this time.
0 commit comments