This repository was archived by the owner on May 4, 2024. It is now read-only.
File tree 3 files changed +55
-0
lines changed
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**package
2
+ * {
3
+ * "name": "indexjs-test",
4
+ * "version": "1.2.3",
5
+ * "description": "Did you know npm could do this, even?",
6
+ * "main": "index.js"
7
+ *
8
+ * but alas, 'twas not to be,
9
+ * for, when parse the comment we,
10
+ * json is not there to see
11
+ *
12
+ * }
13
+ **/
14
+ console . log ( 'just a broken single-file package' )
Original file line number Diff line number Diff line change
1
+ /**package
2
+ * {
3
+ * "name": "indexjs-test",
4
+ * "version": "1.2.3",
5
+ * "description": "Did you know npm could do this, even?",
6
+ * "main": "index.js"
7
+ * }
8
+ **/
9
+ console . log ( 'just a simple single-file package' )
Original file line number Diff line number Diff line change
1
+ const t = require ( 'tap' )
2
+ const read = require ( '../' )
3
+ const { resolve } = require ( 'path' )
4
+ t . test ( 'read from an index.js file' , t => {
5
+ const fixture = resolve ( __dirname , 'fixtures/indexjs/package.json' )
6
+ read ( fixture , ( er , data ) => {
7
+ if ( er ) {
8
+ throw er
9
+ }
10
+ t . match ( data , {
11
+ name : 'indexjs-test' ,
12
+ version : '1.2.3' ,
13
+ description : 'Did you know npm could do this, even?' ,
14
+ main : 'index.js' ,
15
+ readme : 'ERROR: No README data found!' ,
16
+ _id : 'indexjs-test@1.2.3'
17
+ } )
18
+ t . end ( )
19
+ } )
20
+ } )
21
+
22
+ t . test ( 'read broken json' , t => {
23
+ const fixture = resolve ( __dirname , 'fixtures/indexjs-bad/package.json' )
24
+ read ( fixture , ( er , data ) => {
25
+ t . match ( er , {
26
+ code : 'ENOENT' ,
27
+ path : fixture
28
+ } )
29
+ t . notOk ( data )
30
+ t . end ( )
31
+ } )
32
+ } )
You can’t perform that action at this time.
0 commit comments