Socket
Socket
Sign inDemoInstall

cipm

Package Overview
Dependencies
13
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.2 to 0.8.0

node_modules/abbrev/abbrev.js

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="0.8.0"></a>
# [0.8.0](https://github.com/zkat/cipm/compare/v0.7.2...v0.8.0) (2017-11-28)
### Features
* **gyp:** new npm-lifecycle[@2](https://github.com/2) with included node-gyp ([a4ed938](https://github.com/zkat/cipm/commit/a4ed938))
<a name="0.7.2"></a>

@@ -7,0 +17,0 @@ ## [0.7.2](https://github.com/zkat/cipm/compare/v0.7.1...v0.7.2) (2017-10-13)

6

index.js

@@ -129,4 +129,4 @@ 'use strict'

.then(next) // build children between preinstall and binLink
.then(() => dep !== this.tree && // Don't link root bins
binLink(pkg, depPath, false, {
// Don't link root bins
.then(() => !dep.isRoot && binLink(pkg, depPath, false, {
force: this.config.config.force,

@@ -198,3 +198,3 @@ ignoreScripts: this.config.lifecycleOpts.ignoreScripts,

if (
dep !== tree && // never purge root! 🙈
!dep.isRoot && // never purge root! 🙈
!liveDeps.has(dep) &&

@@ -201,0 +201,0 @@ !purged.has(dep)

@@ -5,2 +5,12 @@ # Change Log

<a name="1.1.0"></a>
# [1.1.0](https://github.com/npm/bin-links/compare/v1.0.0...v1.1.0) (2017-11-20)
### Features
* **dos2unix:** Log the fact line endings are being changed upon install. ([e9f8a6f](https://github.com/npm/bin-links/commit/e9f8a6f))
<a name="1.0.0"></a>

@@ -7,0 +17,0 @@ # 1.0.0 (2017-10-07)

@@ -120,3 +120,6 @@ 'use strict'

isHashbangFile(src).then((isHashbang) => {
if (isHashbang) return dos2Unix(src)
if (isHashbang) {
opts.log.silly('linkBins', 'Converting line endings of hashbang file:', src)
return dos2Unix(src)
}
}).then(() => {

@@ -123,0 +126,0 @@ if (!gtop) return cb()

{
"_args": [
[
"bin-links@1.0.0",
"/Users/zkat/Documents/code/cipm"
]
],
"_from": "bin-links@1.0.0",
"_id": "bin-links@1.0.0",
"_from": "bin-links@1.1.0",
"_id": "bin-links@1.1.0",
"_inBundle": false,
"_integrity": "sha512-eRrGL/i19rIGpu8jMNz+C4YkFHSUTJu6Z7sCXj91dWJeC0yeeEEnmIvNpCw3wlDgXsH9tPIjk9tZc88yHSiHdQ==",
"_integrity": "sha512-3desjIEoSt86s+BRZlkLpBPPcHhr4vyUPL/+X1cQuE96NIlkELqnb4Yq+I5gZe47gHsZztA6cm38uMrT9+FWpA==",
"_location": "/bin-links",

@@ -17,14 +11,16 @@ "_phantomChildren": {},

"registry": true,
"raw": "bin-links@1.0.0",
"raw": "bin-links@1.1.0",
"name": "bin-links",
"escapedName": "bin-links",
"rawSpec": "1.0.0",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.0.0.tgz",
"_spec": "1.0.0",
"_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.0.tgz",
"_shasum": "e0a92cb57f01c4dc1088bca2bae6be110b9f64f9",
"_spec": "bin-links@1.1.0",
"_where": "/Users/zkat/Documents/code/cipm",

@@ -37,2 +33,3 @@ "author": {

},
"bundleDependencies": false,
"dependencies": {

@@ -46,2 +43,3 @@ "bluebird": "^3.5.0",

},
"deprecated": false,
"description": "JavaScript package binary linker",

@@ -81,3 +79,3 @@ "devDependencies": {

},
"version": "1.0.0"
"version": "1.1.0"
}

@@ -5,2 +5,13 @@ # Change Log

<a name="2.0.1"></a>
## [2.0.1](https://github.com/npm/gentle-fs/compare/v2.0.0...v2.0.1) (2017-11-28)
### Bug Fixes
* **pkglock:** regenerate lock to fix version issues ([a41cbd0](https://github.com/npm/gentle-fs/commit/a41cbd0))
* **rm:** make sure logic for vacuuming matches original npm ([673e82c](https://github.com/npm/gentle-fs/commit/673e82c))
<a name="2.0.0"></a>

@@ -7,0 +18,0 @@ # [2.0.0](https://github.com/npm/gentle-fs/compare/v1.0.2...v2.0.0) (2017-10-07)

@@ -21,5 +21,6 @@ 'use strict'

var options = {}
if (opts.force) { options.purge = true }
if (opts.base) options.base = path.normalize(path.resolve(opts.prefix, opts.base))
if (opts.force || !opts.gently) {
if (!opts.gently) {
options.purge = true

@@ -26,0 +27,0 @@ return vacuum(targetPath, options, cb)

{
"_args": [
[
"gentle-fs@2.0.0",
"/Users/zkat/Documents/code/cipm"
]
],
"_from": "gentle-fs@2.0.0",
"_id": "gentle-fs@2.0.0",
"_from": "gentle-fs@^2.0.0",
"_id": "gentle-fs@2.0.1",
"_inBundle": false,
"_integrity": "sha512-9VGqvWWPG5OwcVzTYtfo0mHQ4HCaPEAr0VnbCYl2z0l891pYlIwQ7JxwyFr/nXfu0v7R4+oFgZL3bNiXz0D7tQ==",
"_integrity": "sha512-cEng5+3fuARewXktTEGbwsktcldA+YsnUEaXZwcK/3pjSE1X9ObnTs+/8rYf8s+RnIcQm2D5x3rwpN7Zom8Bew==",
"_location": "/gentle-fs",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "gentle-fs@2.0.0",
"raw": "gentle-fs@^2.0.0",
"name": "gentle-fs",
"escapedName": "gentle-fs",
"rawSpec": "2.0.0",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
"fetchSpec": "^2.0.0"
},

@@ -27,5 +21,6 @@ "_requiredBy": [

],
"_resolved": "https://registry.npmjs.org/gentle-fs/-/gentle-fs-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "/Users/zkat/Documents/code/cipm",
"_resolved": "https://registry.npmjs.org/gentle-fs/-/gentle-fs-2.0.1.tgz",
"_shasum": "585cfd612bfc5cd52471fdb42537f016a5ce3687",
"_spec": "gentle-fs@^2.0.0",
"_where": "/Users/zkat/Documents/code/cipm/node_modules/bin-links",
"author": {

@@ -37,2 +32,3 @@ "name": "Mike Sherov"

},
"bundleDependencies": false,
"dependencies": {

@@ -48,2 +44,3 @@ "aproba": "^1.1.2",

},
"deprecated": false,
"description": "Gentle Filesystem operations",

@@ -86,3 +83,3 @@ "devDependencies": {

},
"version": "2.0.0"
"version": "2.0.1"
}

@@ -5,2 +5,23 @@ # Change Log

<a name="2.0.0"></a>
# [2.0.0](https://github.com/npm/lifecycle/compare/v1.0.3...v2.0.0) (2017-11-17)
### Features
* **node-gyp:** use own node-gyp ([ae94ed2](https://github.com/npm/lifecycle/commit/ae94ed2))
* **nodeOptions:** add "nodeOptions" option to set NODE_OPTIONS for child ([#7](https://github.com/npm/lifecycle/issues/7)) ([2eb7a38](https://github.com/npm/lifecycle/commit/2eb7a38))
* **stdio:** add child process io options and default logging of piped stdout/err ([#3](https://github.com/npm/lifecycle/issues/3)) ([7b8281a](https://github.com/npm/lifecycle/commit/7b8281a))
### BREAKING CHANGES
* **node-gyp:** Previously you had to bring your own node-gyp AND you had
to provide access the way npm does, by having a `bin` dir with a
`node-gyp-bin` in it.
Fixes: #4
<a name="1.0.3"></a>

@@ -7,0 +28,0 @@ ## [1.0.3](https://github.com/npm/lifecycle/compare/v1.0.2...v1.0.3) (2017-09-01)

@@ -15,3 +15,7 @@ 'use strict'

const which = require('which')
const byline = require('byline')
const resolveFrom = require('resolve-from')
const DEFAULT_NODE_GYP_PATH = resolveFrom(__dirname, 'node-gyp/bin/node-gyp')
let PATH = 'PATH'

@@ -65,2 +69,3 @@

env.INIT_CWD = process.cwd()
env.npm_config_node_gyp = env.npm_config_node_gyp || DEFAULT_NODE_GYP_PATH

@@ -96,3 +101,3 @@ // 'nobody' typically doesn't have permission to write to /tmp

// the bundled one will be used for installing things.
pathArr.unshift(path.join(__dirname, '..', '..', 'bin', 'node-gyp-bin'))
pathArr.unshift(path.join(__dirname, 'node-gyp-bin'))

@@ -250,3 +255,3 @@ if (shouldPrependCurrentNodeDirToPATH(opts)) {

env: env,
stdio: [ 0, 1, 2 ]
stdio: opts.stdio || [ 0, 1, 2 ]
}

@@ -289,2 +294,8 @@

})
byline(proc.stdout).on('data', function (data) {
opts.log.verbose('lifecycle', logid(pkg, stage), 'stdout', data.toString())
})
byline(proc.stderr).on('data', function (data) {
opts.log.verbose('lifecycle', logid(pkg, stage), 'stderr', data.toString())
})
process.once('SIGTERM', procKill)

@@ -363,2 +374,4 @@ process.once('SIGINT', procInterupt)

if (opts.nodeOptions) env.NODE_OPTIONS = opts.nodeOptions
for (i in data) {

@@ -365,0 +378,0 @@ if (i.charAt(0) !== '_') {

{
"_args": [
[
"npm-lifecycle@1.0.3",
"/Users/zkat/Documents/code/cipm"
]
],
"_from": "npm-lifecycle@1.0.3",
"_id": "npm-lifecycle@1.0.3",
"_from": "npm-lifecycle@latest",
"_id": "npm-lifecycle@2.0.0",
"_inBundle": false,
"_integrity": "sha512-CsdargNux7vbv2oeJg7Jb3AH6LPydR06s051A/6tNBGtHo4USlCzfbRn6mSaJELA0sZpaWfqVUNFQ1arOb6rIg==",
"_integrity": "sha512-aE7H012O01GKXT9BWnsGMLVci+MOgkhpSwq02ok20aXcNHxFs7enfampNMkiOV1DJEU0LynzemwdjbtXahXKcw==",
"_location": "/npm-lifecycle",

@@ -17,16 +11,18 @@ "_phantomChildren": {

"_requested": {
"type": "version",
"type": "tag",
"registry": true,
"raw": "npm-lifecycle@1.0.3",
"raw": "npm-lifecycle@latest",
"name": "npm-lifecycle",
"escapedName": "npm-lifecycle",
"rawSpec": "1.0.3",
"rawSpec": "latest",
"saveSpec": null,
"fetchSpec": "1.0.3"
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-1.0.3.tgz",
"_spec": "1.0.3",
"_resolved": "https://registry.npmjs.org/npm-lifecycle/-/npm-lifecycle-2.0.0.tgz",
"_shasum": "d66fba59e7098dbb5862df66c0d81ed75108f1c6",
"_spec": "npm-lifecycle@latest",
"_where": "/Users/zkat/Documents/code/cipm",

@@ -39,4 +35,8 @@ "author": {

},
"bundleDependencies": false,
"dependencies": {
"byline": "^5.0.0",
"graceful-fs": "^4.1.11",
"node-gyp": "^3.6.2",
"resolve-from": "^4.0.0",
"slide": "^1.1.6",

@@ -47,5 +47,7 @@ "uid-number": "0.0.6",

},
"deprecated": false,
"description": "JavaScript package lifecycle hook runner",
"devDependencies": {
"nyc": "^11.1.0",
"sinon": "^4.0.1",
"standard": "^10.0.3",

@@ -59,3 +61,4 @@ "standard-version": "^4.2.0",

"index.js",
"lib/spawn.js"
"lib/spawn.js",
"node-gyp-bin"
],

@@ -85,3 +88,3 @@ "homepage": "https://github.com/npm/lifecycle#readme",

},
"version": "1.0.3"
"version": "2.0.0"
}

@@ -41,2 +41,7 @@ # npm-lifecycle [![npm version](https://img.shields.io/npm/v/npm-lifecycle.svg)](https://npm.im/npm-lifecycle) [![license](https://img.shields.io/npm/l/npm-lifecycle.svg)](https://npm.im/npm-lifecycle) [![Travis](https://img.shields.io/travis/npm/lifecycle.svg)](https://travis-ci.org/npm/lifecycle) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/npm/lifecycle?svg=true)](https://ci.appveyor.com/project/npm/lifecycle) [![Coverage Status](https://coveralls.io/repos/github/npm/lifecycle/badge.svg?branch=latest)](https://coveralls.io/github/npm/lifecycle?branch=latest)

##### Arguments
* `opts.stdio` - the [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio)
passed to the child process. `[0, 1, 2]` by default.
##### Example

@@ -43,0 +48,0 @@

@@ -21,2 +21,11 @@ 'use strict'

let spec
if (typeof arg === 'object') {
if (arg instanceof Result && (!where || where === arg.where)) {
return arg
} else if (arg.name && arg.rawSpec) {
return npa.resolve(arg.name, arg.rawSpec, where || arg.where)
} else {
return npa(arg.raw, where || arg.where)
}
}
const nameEndsAt = arg[0] === '@' ? arg.slice(1).indexOf('@') + 1 : arg.indexOf('@')

@@ -135,6 +144,4 @@ const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg

res.gitCommittish = null
} else if (committish == null || committish === '') {
res.gitCommittish = 'master'
} else {
res.gitCommittish = committish
res.gitCommittish = committish === '' ? null : committish
}

@@ -209,3 +216,3 @@ return res

fetchSpec: matched[1],
gitCommittish: matched[2] || 'master'
gitCommittish: matched[2] == null ? null : matched[2]
}

@@ -212,0 +219,0 @@ }

{
"_args": [
[
"npm-package-arg@5.1.2",
"/Users/zkat/Documents/code/cipm"
]
],
"_from": "npm-package-arg@5.1.2",
"_id": "npm-package-arg@5.1.2",
"_from": "npm-package-arg@6.0.0",
"_id": "npm-package-arg@6.0.0",
"_inBundle": false,
"_integrity": "sha512-wJBsrf0qpypPT7A0LART18hCdyhpCMxeTtcb0X4IZO2jsP6Om7EHN1d9KSKiqD+KVH030RVNpWS9thk+pb7wzA==",
"_integrity": "sha512-hwC7g81KLgRmchv9ol6f3Fx4Yyc9ARX5X5niDHVILgpuvf08JRIgOZcEfpFXli3BgESoTrkauqorXm6UbvSgSg==",
"_location": "/npm-package-arg",

@@ -17,17 +11,16 @@ "_phantomChildren": {},

"registry": true,
"raw": "npm-package-arg@5.1.2",
"raw": "npm-package-arg@6.0.0",
"name": "npm-package-arg",
"escapedName": "npm-package-arg",
"rawSpec": "5.1.2",
"rawSpec": "6.0.0",
"saveSpec": null,
"fetchSpec": "5.1.2"
"fetchSpec": "6.0.0"
},
"_requiredBy": [
"/",
"/lock-verify",
"/npm-pick-manifest",
"/pacote"
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-5.1.2.tgz",
"_spec": "5.1.2",
"_resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-6.0.0.tgz",
"_shasum": "8cce04b49d3f9faec3f56b0fe5f4391aeb9d2fac",
"_spec": "npm-package-arg@6.0.0",
"_where": "/Users/zkat/Documents/code/cipm",

@@ -42,8 +35,10 @@ "author": {

},
"bundleDependencies": false,
"dependencies": {
"hosted-git-info": "^2.4.2",
"hosted-git-info": "^2.5.0",
"osenv": "^0.1.4",
"semver": "^5.1.0",
"semver": "^5.4.1",
"validate-npm-package-name": "^3.0.0"
},
"deprecated": false,
"description": "Parse the things that can be arguments to `npm install`",

@@ -71,3 +66,3 @@ "devDependencies": {

},
"version": "5.1.2"
"version": "6.0.0"
}
# npm-package-arg
[![Build Status](https://travis-ci.org/npm/npm-package-arg.svg?branch=master)](https://travis-ci.org/npm/npm-package-arg)
Parses package name and specifier passed to commands like `npm install` or

@@ -4,0 +6,0 @@ `npm cache add`, or as found in `package.json` dependency sections.

@@ -5,3 +5,3 @@ 'use strict'

maxCallsPerWorker : Infinity
, maxConcurrentWorkers : require('os').cpus().length
, maxConcurrentWorkers : (require('os').cpus() || { length: 1 }).length
, maxConcurrentCallsPerWorker : 10

@@ -8,0 +8,0 @@ , maxConcurrentCalls : Infinity

@@ -18,2 +18,6 @@ 'use strict'

child.on('error', function() {
// this *should* be picked up by onExit and the operation requeued
})
child.send({ module: forkModule })

@@ -23,9 +27,3 @@

return {
send : function (data) {
try {
child.send(data)
} catch (e) {
// this *should* be picked up by onExit and the operation requeued
}
}
send : child.send.bind(child)
, child : child

@@ -32,0 +30,0 @@ }

{
"_args": [
[
"worker-farm@1.5.0",
"/Users/zkat/Documents/code/cipm"
]
],
"_from": "worker-farm@1.5.0",
"_id": "worker-farm@1.5.0",
"_from": "worker-farm@1.5.2",
"_id": "worker-farm@1.5.2",
"_inBundle": false,
"_integrity": "sha512-DHRiUggxtbruaTwnLDm2/BRDKZIoOYvrgYUj5Bam4fU6Gtvc0FaEyoswFPBjMXAweGW2H4BDNIpy//1yXXuaqQ==",
"_integrity": "sha512-XxiQ9kZN5n6mmnW+mFJ+wXjNNI/Nx4DIdaAKLX1Bn6LYBWlN/zaBhu34DQYPZ1AJobQuu67S2OfDdNSVULvXkQ==",
"_location": "/worker-farm",

@@ -17,14 +11,16 @@ "_phantomChildren": {},

"registry": true,
"raw": "worker-farm@1.5.0",
"raw": "worker-farm@1.5.2",
"name": "worker-farm",
"escapedName": "worker-farm",
"rawSpec": "1.5.0",
"rawSpec": "1.5.2",
"saveSpec": null,
"fetchSpec": "1.5.0"
"fetchSpec": "1.5.2"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.5.0.tgz",
"_spec": "1.5.0",
"_resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.5.2.tgz",
"_shasum": "32b312e5dc3d5d45d79ef44acc2587491cd729ae",
"_spec": "worker-farm@1.5.2",
"_where": "/Users/zkat/Documents/code/cipm",

@@ -37,2 +33,3 @@ "authors": [

},
"bundleDependencies": false,
"dependencies": {

@@ -42,2 +39,3 @@ "errno": "^0.1.4",

},
"deprecated": false,
"description": "Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.",

@@ -65,3 +63,3 @@ "devDependencies": {

"types": "./index.d.ts",
"version": "1.5.0"
"version": "1.5.2"
}
'use strict'
const fs = require('fs')
const started = Date.now()

@@ -82,5 +83,4 @@

let started = Date.now()
module.exports.uptime = function(callback) {
module.exports.uptime = function (callback) {
callback(null, Date.now() - started)
}

@@ -129,13 +129,14 @@ 'use strict'

tape('auto start workers', function (t) {
t.plan(4)
let child = workerFarm({ maxConcurrentWorkers: 3, autoStart: true }, childPath, ['uptime'])
, pids = []
, i = 3
, delay = 150
, count = 5
, i = count
, delay = 250
t.plan(count + 1)
setTimeout(function() {
while (i--)
child.uptime(function (err, uptime) {
t.ok(uptime > 10, 'child has been up before the request')
t.ok(uptime > 10, 'child has been up before the request (' + uptime + 'ms)')
})

@@ -155,5 +156,11 @@

let child = workerFarm({ maxConcurrentWorkers: 1, maxCallsPerWorker: 1 }, childPath)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: 1
, autoStart: true
}, childPath)
, pids = []
, i = 10
, count = 25
, i = count

@@ -163,8 +170,8 @@ while (i--) {

pids.push(pid)
if (pids.length == 10) {
t.equal(10, uniq(pids).length, 'one process for each call (by pid)')
if (pids.length == count) {
t.equal(count, uniq(pids).length, 'one process for each call (by pid)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (pids.length > 10)
} else if (pids.length > count)
t.fail('too many callbacks!')

@@ -181,5 +188,11 @@ })

let child = workerFarm({ maxConcurrentWorkers: 1, maxCallsPerWorker: 2 }, childPath)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: 2
, autoStart: true
}, childPath)
, pids = []
, i = 10
, count = 20
, i = count

@@ -189,8 +202,8 @@ while (i--) {

pids.push(pid)
if (pids.length == 10) {
t.equal(5, uniq(pids).length, 'one process for each call (by pid)')
if (pids.length == count) {
t.equal(count / 2, uniq(pids).length, 'one process for each call (by pid)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (pids.length > 10)
} else if (pids.length > count)
t.fail('too many callbacks!')

@@ -206,19 +219,30 @@ })

let child = workerFarm({ maxConcurrentWorkers: 1 }, childPath)
, i = 10
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 200
, count = 200
, i = count
, cbc = 0
, start = Date.now()
while (i--) {
child(100, function () {
if (++cbc == 10) {
let time = Date.now() - start
t.ok(time > 100 && time < 250, 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > 10)
t.fail('too many callbacks!')
})
}
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// upper-limit not tied to `count` at all
t.ok(time > defer && time < (defer * 2.5), 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})

@@ -232,22 +256,31 @@

let child = workerFarm(
{ maxConcurrentWorkers: 1, maxConcurrentCallsPerWorker: 1 }
, childPath
)
, i = 10
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: 1
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 20
, count = 100
, i = count
, cbc = 0
, start = Date.now()
while (i--) {
child(20, function () {
if (++cbc == 10) {
let time = Date.now() - start
t.ok(time > 200 && time < 400, 'processed tasks sequentially (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > 10)
t.fail('too many callbacks!')
})
}
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// upper-limit tied closely to `count`, 1.2 is generous but accounts for all the timers
// coming back at the same time and the IPC overhead
t.ok(time > (defer * count) && time < (defer * count * 1.2), 'processed tasks sequentially (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})

@@ -260,19 +293,33 @@

let child = workerFarm({ maxConcurrentWorkers: 1, maxConcurrentCallsPerWorker: 5 }, childPath)
, i = 10
let callsPerWorker = 5
, child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: callsPerWorker
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 100
, count = 100
, i = count
, cbc = 0
, start = Date.now()
while (i--) {
child(100, function () {
if (++cbc == 10) {
let time = Date.now() - start
t.ok(time > 200 && time < 350, 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > 10)
t.fail('too many callbacks!')
})
}
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// (defer * (count / callsPerWorker + 1)) - if precise it'd be count/callsPerWorker
// but accounting for IPC and other overhead, we need to give it a bit of extra time,
// hence the +1
t.ok(time > (defer * 1.5) && time < (defer * (count / callsPerWorker + 1)), 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})

@@ -289,3 +336,4 @@

, pids = []
, i = 10
, count = 10
, i = count

@@ -296,9 +344,9 @@ while (i--) {

pids.push(pid)
if (ids.length == 10) {
if (ids.length == count) {
t.ok(uniq(pids).length > 2, 'processed by many (' + uniq(pids).length + ') workers, but got there in the end!')
t.ok(uniq(ids).length == 10, 'received a single result for each unique call')
t.ok(uniq(ids).length == count, 'received a single result for each unique call')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (ids.length > 10)
} else if (ids.length > count)
t.fail('too many callbacks!')

@@ -305,0 +353,0 @@ })

'use strict'
const inspect = require('util').inspect
const path = require('path')
const inspect = require('util').inspect
const camelCase = require('camelcase')
const Parser = require('yargs-parser')
const DEFAULT_MARKER = '*'
const DEFAULT_MARKER = /(^\*)|(^\$0)/

@@ -46,3 +47,3 @@ // handles parsing positional arguments,

const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
if (c === DEFAULT_MARKER) {
if (DEFAULT_MARKER.test(c)) {
isDefault = true

@@ -53,15 +54,5 @@ return false

})
// standardize on $0 for default command.
if (parsedAliases.length === 0 && isDefault) parsedAliases.push('$0')
// short-circuit if default with no aliases
if (isDefault && parsedAliases.length === 0) {
defaultCommand = {
original: cmd.replace(DEFAULT_MARKER, '').trim(),
handler,
builder: builder || {},
demanded: parsedCommand.demanded,
optional: parsedCommand.optional
}
return
}
// shift cmd and aliases after filtering out '*'

@@ -85,2 +76,3 @@ if (isDefault) {

original: cmd,
description: description,
handler,

@@ -186,4 +178,6 @@ builder: builder || {},

let positionalMap = {}
if (command) currentContext.commands.push(command)
if (command) {
currentContext.commands.push(command)
currentContext.fullCommands.push(commandHandler.original)
}
if (typeof commandHandler.builder === 'function') {

@@ -198,4 +192,7 @@ // a function can be provided, which builds

if (yargs.parsed === false) {
if (typeof yargs.getUsageInstance().getUsage() === 'undefined') {
yargs.usage(`$0 ${parentCommands.length ? `${parentCommands.join(' ')} ` : ''}${commandHandler.original}`)
if (shouldUpdateUsage(yargs)) {
yargs.getUsageInstance().usage(
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
commandHandler.description
)
}

@@ -213,3 +210,8 @@ innerArgv = innerYargs ? innerYargs._parseArgs(null, null, true, commandIndex) : yargs._parseArgs(null, null, true, commandIndex)

innerYargs = yargs.reset(parsed.aliases)
innerYargs.usage(`$0 ${parentCommands.length ? `${parentCommands.join(' ')} ` : ''}${commandHandler.original}`)
if (shouldUpdateUsage(innerYargs)) {
innerYargs.getUsageInstance().usage(
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
commandHandler.description
)
}
Object.keys(commandHandler.builder).forEach((key) => {

@@ -235,3 +237,6 @@ innerYargs.option(key, commandHandler.builder[key])

if (command) currentContext.commands.pop()
if (command) {
currentContext.commands.pop()
currentContext.fullCommands.pop()
}
numFiles = currentContext.files.length - numFiles

@@ -243,2 +248,34 @@ if (numFiles > 0) currentContext.files.splice(numFiles * -1, numFiles)

function shouldUpdateUsage (yargs) {
return !yargs.getUsageInstance().getUsageDisabled() &&
yargs.getUsageInstance().getUsage().length === 0
}
function usageFromParentCommandsCommandHandler (parentCommands, commandHandler) {
const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, '').trim() : commandHandler.original
const pc = parentCommands.filter((c) => { return !DEFAULT_MARKER.test(c) })
pc.push(c)
return `$0 ${pc.join(' ')}`
}
self.runDefaultBuilderOn = function (yargs) {
if (shouldUpdateUsage(yargs)) {
// build the root-level command string from the default string.
const commandString = DEFAULT_MARKER.test(defaultCommand.original)
? defaultCommand.original : defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ')
yargs.getUsageInstance().usage(
commandString,
defaultCommand.description
)
}
const builder = defaultCommand.builder
if (typeof builder === 'function') {
builder(yargs)
} else {
Object.keys(builder).forEach((key) => {
yargs.option(key, builder[key])
})
}
}
// transcribe all positional arguments "command <foo> <bar> [apple]"

@@ -256,3 +293,3 @@ // onto argv.

const demand = demanded.shift()
populatePositional(demand, argv, yargs, positionalMap)
populatePositional(demand, argv, positionalMap)
}

@@ -262,50 +299,97 @@

const maybe = optional.shift()
populatePositional(maybe, argv, yargs, positionalMap)
populatePositional(maybe, argv, positionalMap)
}
argv._ = context.commands.concat(argv._)
postProcessPositionals(argv, positionalMap, self.cmdToParseOptions(commandHandler.original))
return positionalMap
}
// populate a single positional argument and its
// aliases onto argv.
function populatePositional (positional, argv, yargs, positionalMap) {
// "positional" consists of the positional.cmd, an array representing
// the positional's name and aliases, and positional.variadic
// indicating whether or not it is a variadic array.
let variadics = null
let value = null
for (let i = 0, cmd; (cmd = positional.cmd[i]) !== undefined; i++) {
if (positional.variadic) {
if (variadics) argv[cmd] = variadics.slice(0)
else argv[cmd] = variadics = argv._.splice(0)
} else {
if (!value && !argv._.length) continue
if (value) argv[cmd] = value
else argv[cmd] = value = argv._.shift()
}
positionalMap[cmd] = true
postProcessPositional(yargs, argv, cmd)
addCamelCaseExpansions(argv, cmd)
function populatePositional (positional, argv, positionalMap, parseOptions) {
const cmd = positional.cmd[0]
if (positional.variadic) {
positionalMap[cmd] = argv._.splice(0).map(String)
} else {
if (argv._.length) positionalMap[cmd] = [String(argv._.shift())]
}
}
// TODO move positional arg logic to yargs-parser and remove this duplication
function postProcessPositional (yargs, argv, key) {
const coerce = yargs.getOptions().coerce[key]
if (typeof coerce === 'function') {
try {
argv[key] = coerce(argv[key])
} catch (err) {
yargs.getUsageInstance().fail(err.message, err)
}
// we run yargs-parser against the positional arguments
// applying the same parsing logic used for flags.
function postProcessPositionals (argv, positionalMap, parseOptions) {
// combine the parsing hints we've inferred from the command
// string with explicitly configured parsing hints.
const options = Object.assign({}, yargs.getOptions())
options.default = Object.assign(parseOptions.default, options.default)
options.alias = Object.assign(parseOptions.alias, options.alias)
options.array = options.array.concat(parseOptions.array)
const unparsed = []
Object.keys(positionalMap).forEach((key) => {
positionalMap[key].map((value) => {
unparsed.push(`--${key}`)
unparsed.push(value)
})
})
// short-circuit parse.
if (!unparsed.length) return
const parsed = Parser.detailed(unparsed, options)
if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
} else {
// only copy over positional keys (don't overwrite
// flag arguments that were already parsed).
const positionalKeys = Object.keys(positionalMap)
Object.keys(positionalMap).forEach((key) => {
[].push.apply(positionalKeys, parsed.aliases[key])
})
Object.keys(parsed.argv).forEach((key) => {
if (positionalKeys.indexOf(key) !== -1) {
argv[key] = parsed.argv[key]
}
})
}
}
function addCamelCaseExpansions (argv, option) {
if (/-/.test(option)) {
const cc = camelCase(option)
if (typeof argv[option] === 'object') argv[cc] = argv[option].slice(0)
else argv[cc] = argv[option]
self.cmdToParseOptions = function (cmdString) {
const parseOptions = {
array: [],
default: {},
alias: {},
demand: {}
}
const parsed = self.parseCommand(cmdString)
parsed.demanded.forEach((d) => {
const cmds = d.cmd.slice(0)
const cmd = cmds.shift()
if (d.variadic) {
parseOptions.array.push(cmd)
parseOptions.default[cmd] = []
}
cmds.forEach((c) => {
parseOptions.alias[cmd] = c
})
parseOptions.demand[cmd] = true
})
parsed.optional.forEach((o) => {
const cmds = o.cmd.slice(0)
const cmd = cmds.shift()
if (o.variadic) {
parseOptions.array.push(cmd)
parseOptions.default[cmd] = []
}
cmds.forEach((c) => {
parseOptions.alias[cmd] = c
})
})
return parseOptions
}

@@ -312,0 +396,0 @@

@@ -81,3 +81,3 @@ 'use strict'

// generate the completion script to add to your .bashrc.
self.generateCompletionScript = function generateCompletionScript ($0) {
self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
let script = fs.readFileSync(

@@ -93,2 +93,3 @@ path.resolve(__dirname, '../completion.sh.hbs'),

script = script.replace(/{{app_name}}/g, name)
script = script.replace(/{{completion_command}}/g, cmd)
return script.replace(/{{app_path}}/g, $0)

@@ -95,0 +96,0 @@ }

@@ -6,2 +6,3 @@ 'use strict'

const objFilter = require('./obj-filter')
const path = require('path')
const setBlocking = require('set-blocking')

@@ -68,8 +69,25 @@ const YError = require('./yerror')

// methods for ouputting/building help (usage) message.
let usage
self.usage = (msg) => {
usage = msg
let usages = []
let usageDisabled = false
self.usage = (msg, description) => {
if (msg === null) {
usageDisabled = true
usages = []
return
}
usageDisabled = false
usages.push([msg, description || ''])
return self
}
self.getUsage = () => usage
self.getUsage = () => {
return usages
}
self.getUsageDisabled = () => {
return usageDisabled
}
self.getPositionalGroupName = () => {
return __('Positionals:')
}
let examples = []

@@ -134,2 +152,3 @@ self.example = (cmd, description) => {

// handle old demanded API
const base$0 = path.basename(yargs.$0)
const demandedOptions = yargs.getDemandedOptions()

@@ -157,5 +176,22 @@ const demandedCommands = yargs.getDemandedCommands()

// the usage string.
if (usage) {
const u = usage.replace(/\$0/g, yargs.$0)
ui.div(`${u}\n`)
if (!usageDisabled) {
if (usages.length) {
// user-defined usage.
usages.forEach((usage) => {
ui.div(`${usage[0].replace(/\$0/g, base$0)}`)
if (usage[1]) {
ui.div({text: `${usage[1]}`, padding: [1, 0, 0, 0]})
}
})
ui.div()
} else if (commands.length) {
let u = null
// demonstrate how commands are used.
if (demandedCommands._) {
u = `${base$0} <${__('command')}>\n`
} else {
u = `${base$0} [${__('command')}]\n`
}
ui.div(`${u}`)
}
}

@@ -168,5 +204,13 @@

const context = yargs.getContext()
const parentCommands = context.commands.length ? `${context.commands.join(' ')} ` : ''
commands.forEach((command) => {
const commandString = `${base$0} ${parentCommands}${command[0].replace(/^\$0 ?/, '')}` // drop $0 from default commands.
ui.span(
{text: command[0], padding: [0, 2, 0, 2], width: maxWidth(commands, theWrap) + 4},
{
text: commandString,
padding: [0, 2, 0, 2],
width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
},
{text: command[1]}

@@ -220,3 +264,8 @@ )

acc[key] = [ key ].concat(options.alias[key] || [])
.map(sw => (sw.length > 1 ? '--' : '-') + sw)
.map(sw => {
// for the special positional group don't
// add '--' or '-' prefix.
if (groupName === self.getPositionalGroupName()) return sw
else return (sw.length > 1 ? '--' : '-') + sw
})
.join(', ')

@@ -266,3 +315,3 @@

examples.forEach((example) => {
example[0] = example[0].replace(/\$0/g, yargs.$0)
example[0] = example[0].replace(/\$0/g, base$0)
})

@@ -296,3 +345,3 @@

if (epilog) {
const e = epilog.replace(/\$0/g, yargs.$0)
const e = epilog.replace(/\$0/g, base$0)
ui.div(`${e}\n`)

@@ -306,3 +355,3 @@ }

// in the left-hand column of a table.
function maxWidth (table, theWrap) {
function maxWidth (table, theWrap, modifier) {
let width = 0

@@ -317,3 +366,6 @@

table.forEach((v) => {
width = Math.max(stringWidth(v[0]), width)
width = Math.max(
stringWidth(modifier ? `${modifier} ${v[0]}` : v[0]),
width
)
})

@@ -448,3 +500,4 @@

failureOutput = false
usage = undefined
usages = []
usageDisabled = false
epilog = undefined

@@ -462,3 +515,4 @@ examples = []

frozen.failureOutput = failureOutput
frozen.usage = usage
frozen.usages = usages
frozen.usageDisabled = usageDisabled
frozen.epilog = epilog

@@ -472,3 +526,4 @@ frozen.examples = examples

failureOutput = frozen.failureOutput
usage = frozen.usage
usages = frozen.usages
usageDisabled = frozen.usageDisabled
epilog = frozen.epilog

@@ -475,0 +530,0 @@ examples = frozen.examples

@@ -39,3 +39,5 @@ {

"Did you mean %s?": "Did you mean %s?",
"Arguments %s and %s are mutually exclusive" : "Arguments %s and %s are mutually exclusive"
"Arguments %s and %s are mutually exclusive" : "Arguments %s and %s are mutually exclusive",
"Positionals:": "Positionals:",
"command": "command"
}

@@ -38,3 +38,6 @@ {

"Show version number": "Version संख्या दिखाएँ",
"Did you mean %s?": "क्या आपका मतलब है %s?"
"Did you mean %s?": "क्या आपका मतलब है %s?",
"Arguments %s and %s are mutually exclusive" : "तर्क %s और %s परस्पर अनन्य हैं",
"Positionals:": "स्थानीय:",
"command": "आदेश"
}

@@ -39,3 +39,6 @@

"Show version number": "Lihat nomor versi",
"Did you mean %s?": "Maksud Anda: %s?"
"Did you mean %s?": "Maksud Anda: %s?",
"Arguments %s and %s are mutually exclusive" : "Argumen %s dan %s saling eksklusif",
"Positionals:": "Posisional-posisional:",
"command": "perintah"
}

@@ -38,3 +38,6 @@ {

"Show version number": "バージョンを表示",
"Did you mean %s?": "もしかして %s?"
"Did you mean %s?": "もしかして %s?",
"Arguments %s and %s are mutually exclusive" : "引数 %s と %s は同時に指定できません",
"Positionals:": "位置:",
"command": "コマンド"
}

@@ -38,3 +38,6 @@ {

"Show version number": "버전 넘버를 보여줍니다",