Skip to content

Commit 31ee658

Browse files
authored
Merge pull request #1 from Skelp/develop
Release 0.1.0
2 parents c562858 + 7bed412 commit 31ee658

47 files changed

Lines changed: 3684 additions & 13 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
888 888 888 Y88b. Y88b d88P Y88b. 888 888 888 888
88
888 "Y888888 "Y8888P "Y8888P" "Y8888P "Y888888 888 888
99

10-
[PacScan](https://github.com/Skelp/node-pacscan) provide information about all available packages for your module at
11-
runtime.
12-
13-
> This library is very much still in early development! Watch this space.
10+
[PacScan](https://github.com/Skelp/node-pacscan) provides information about all available packages for your module at
11+
runtime by scanning `node_modules` as opposed to digging into dependency trees.
1412

1513
[![Build](https://img.shields.io/travis/Skelp/node-pacscan/develop.svg?style=flat-square)](https://travis-ci.org/Skelp/node-pacscan)
1614
[![Coverage](https://img.shields.io/coveralls/Skelp/node-pacscan/develop.svg?style=flat-square)](https://coveralls.io/github/Skelp/node-pacscan)
@@ -37,11 +35,65 @@ You'll need to have at least [Node.js](https://nodejs.org) 4 or newer.
3735

3836
### `pacscan([options])`
3937

40-
TODO: Document
38+
Scans for all packages available to your module asynchronously, returning a `Promise` to retrieve all of the package
39+
information, each of which will be in a format similar to the following:
40+
41+
``` javascript
42+
{
43+
// The directory of the package
44+
directory: '/path/to/my-example-package/node_modules/example-server',
45+
// The file path of the "main" file for the package or null if it has none
46+
main: '/path/to/my-example-package/node_modules/example-server/server.js',
47+
// The name of the package
48+
name: 'example-server',
49+
// The version of the package
50+
version: '3.2.1'
51+
}
52+
```
53+
54+
The `options` parameter is entirely optional and supports the following:
55+
56+
| Option | Description | Default Value |
57+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
58+
| `includeParents` | Whether the highest level package directory should be scanned or only the lowest level base directory. | `false` |
59+
| `knockknock` | Any options to be passed to [KnockKnock](https://github.com/Skelp/node-knockknock). `limit` will always be overridden to `1`. | `null` |
60+
| `path` | The file/directory path from where to derive the base directory to be scanned. Path to module that called PacScan will be used when `null`. | `null` |
61+
62+
If you only want to list the packages available to your module/package:
63+
64+
``` javascript
65+
const pacscan = require('pacscan')
66+
67+
module.exports = function() {
68+
pacscan()
69+
.then((packages) => {
70+
console.log(`${packages.length} packages found`)
71+
72+
// ...
73+
})
74+
}
75+
```
76+
77+
However, if you're calling PacScan from within a library that is most likely being included in another package as a
78+
dependency. In these cases, you might want to know all of the packages available in the base package (i.e. the highest
79+
level package that is not a dependency itself). All that you need to do for this is to enable the `includeParents`
80+
option.
4181

4282
### `pacscan.sync([options])`
4383

44-
TODO: Document
84+
A synchronous alternative to `pacscan([options])`.
85+
86+
``` javascript
87+
const pacscan = require('pacscan')
88+
89+
module.exports = function() {
90+
const packages = pacscan.sync()
91+
92+
console.log(`${packages.length} packages found`)
93+
94+
// ...
95+
}
96+
```
4597

4698
### `pacscan.version`
4799

@@ -51,7 +103,7 @@ The current version of PacScan.
51103
const pacscan = require('pacscan')
52104

53105
pacscan.version
54-
=> "0.1.0alpha"
106+
=> "0.1.0"
55107
```
56108

57109
## Bugs

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pacscan",
3-
"version": "0.1.0alpha",
3+
"version": "0.1.0",
44
"description": "Scans for available packages",
55
"homepage": "https://github.com/Skelp/node-pacscan",
66
"bugs": {
@@ -23,6 +23,8 @@
2323
},
2424
"dependencies": {
2525
"debug": "*",
26+
"glob": "^7.1.1",
27+
"knockknock": "^0.2.0",
2628
"pkg-dir": "^1.0.0"
2729
},
2830
"devDependencies": {
@@ -31,15 +33,17 @@
3133
"eslint": "^3.16.0",
3234
"eslint-config-skelp": "^0.1.5",
3335
"istanbul": "^0.4.5",
34-
"mocha": "^3.2.0"
36+
"mkdirp": "^0.5.1",
37+
"mocha": "^3.2.0",
38+
"ncp": "^2.0.0",
39+
"tmp": "^0.0.31"
3540
},
3641
"main": "src/pacscan.js",
3742
"scripts": {
3843
"report-coverage": "istanbul cover _mocha --report lcovonly -- -R spec \"test/**/*.spec.js\" && coveralls < coverage/lcov.info",
39-
"test": "npm run test-lint && npm run test-suite && npm run test-coverage",
40-
"test-coverage": "istanbul check-coverage",
41-
"test-lint": "eslint \"src/**/*.js\" \"test/**/*.js\"",
42-
"test-suite": "istanbul cover _mocha -- -R spec \"test/**/*.spec.js\""
44+
"pretest": "eslint \"src/**/*.js\" \"test/**/*.js\"",
45+
"test": "istanbul cover _mocha -- -R spec \"test/**/*.spec.js\"",
46+
"posttest": "istanbul check-coverage"
4347
},
4448
"engines": {
4549
"node": ">=4"

0 commit comments

Comments
 (0)