This repository has been archived by the owner on May 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/**package | ||
* { | ||
* "name": "indexjs-test", | ||
* "version": "1.2.3", | ||
* "description": "Did you know npm could do this, even?", | ||
* "main": "index.js" | ||
* | ||
* but alas, 'twas not to be, | ||
* for, when parse the comment we, | ||
* json is not there to see | ||
* | ||
* } | ||
**/ | ||
console.log('just a broken single-file package') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/**package | ||
* { | ||
* "name": "indexjs-test", | ||
* "version": "1.2.3", | ||
* "description": "Did you know npm could do this, even?", | ||
* "main": "index.js" | ||
* } | ||
**/ | ||
console.log('just a simple single-file package') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const t = require('tap') | ||
const read = require('../') | ||
const { resolve } = require('path') | ||
t.test('read from an index.js file', t => { | ||
const fixture = resolve(__dirname, 'fixtures/indexjs/package.json') | ||
read(fixture, (er, data) => { | ||
if (er) { | ||
throw er | ||
} | ||
t.match(data, { | ||
name: 'indexjs-test', | ||
version: '1.2.3', | ||
description: 'Did you know npm could do this, even?', | ||
main: 'index.js', | ||
readme: 'ERROR: No README data found!', | ||
_id: '[email protected]' | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
|
||
t.test('read broken json', t => { | ||
const fixture = resolve(__dirname, 'fixtures/indexjs-bad/package.json') | ||
read(fixture, (er, data) => { | ||
t.match(er, { | ||
code: 'ENOENT', | ||
path: fixture | ||
}) | ||
t.notOk(data) | ||
t.end() | ||
}) | ||
}) |