diff options
author | isaacs <i@izs.me> | 2019-06-29 00:48:01 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2019-06-30 06:23:54 +0300 |
commit | f5e8849098197493b5785dbef50cad14b2827346 (patch) | |
tree | f4eb2e965d5bdb4df68d7ef8a1b902311d33f2ad /node_modules/readdir-scoped-modules | |
parent | e9411c6cd00323fe377e82dc14a430d736c7e292 (diff) |
npm-registry-mock@1.2.1
Diffstat (limited to 'node_modules/readdir-scoped-modules')
12 files changed, 69 insertions, 38 deletions
diff --git a/node_modules/readdir-scoped-modules/.travis.yml b/node_modules/readdir-scoped-modules/.travis.yml deleted file mode 100644 index e1bcee1ac..000000000 --- a/node_modules/readdir-scoped-modules/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -before_script: npm install -g npm@latest -node_js: - - '0.8' - - '0.10' - - '0.12' - - 'iojs' diff --git a/node_modules/readdir-scoped-modules/package.json b/node_modules/readdir-scoped-modules/package.json index 92afa2d99..08e6e67b2 100644 --- a/node_modules/readdir-scoped-modules/package.json +++ b/node_modules/readdir-scoped-modules/package.json @@ -1,34 +1,31 @@ { - "_args": [ - [ - "readdir-scoped-modules@1.0.2", - "/Users/rebecca/code/npm" - ] - ], - "_from": "readdir-scoped-modules@1.0.2", - "_id": "readdir-scoped-modules@1.0.2", + "_from": "readdir-scoped-modules@*", + "_id": "readdir-scoped-modules@1.1.0", "_inBundle": false, - "_integrity": "sha1-n6+jfShr5dksuuve4DDcm19AZ0c=", + "_integrity": "sha512-asaikDeqAQg7JifRsZn1NJZXo9E+VwlyCfbkZhwyISinqk5zNS6266HS5kah6P0SaQKGF6SkNnZVHUzHFYxYDw==", "_location": "/readdir-scoped-modules", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "range", "registry": true, - "raw": "readdir-scoped-modules@1.0.2", + "raw": "readdir-scoped-modules@*", "name": "readdir-scoped-modules", "escapedName": "readdir-scoped-modules", - "rawSpec": "1.0.2", + "rawSpec": "*", "saveSpec": null, - "fetchSpec": "1.0.2" + "fetchSpec": "*" }, "_requiredBy": [ + "#USER", "/", + "/npm-registry-mock", "/read-installed", "/read-package-tree" ], - "_resolved": "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz", - "_spec": "1.0.2", - "_where": "/Users/rebecca/code/npm", + "_resolved": "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz", + "_shasum": "8d45407b4f870a0dcaebc0e28670d18e74514309", + "_spec": "readdir-scoped-modules@*", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -37,12 +34,14 @@ "bugs": { "url": "https://github.com/npm/readdir-scoped-modules/issues" }, + "bundleDependencies": false, "dependencies": { "debuglog": "^1.0.1", "dezalgo": "^1.0.0", "graceful-fs": "^4.1.2", "once": "^1.3.0" }, + "deprecated": false, "description": "Like `fs.readdir` but handling `@org/module` dirs as if they were a single entry.", "devDependencies": { "tap": "^1.2.0" @@ -50,6 +49,9 @@ "directories": { "test": "test" }, + "files": [ + "readdir.js" + ], "homepage": "https://github.com/npm/readdir-scoped-modules", "license": "ISC", "main": "readdir.js", @@ -61,5 +63,5 @@ "scripts": { "test": "tap test/*.js" }, - "version": "1.0.2" + "version": "1.1.0" } diff --git a/node_modules/readdir-scoped-modules/readdir.js b/node_modules/readdir-scoped-modules/readdir.js index efbe5526d..806d78705 100644 --- a/node_modules/readdir-scoped-modules/readdir.js +++ b/node_modules/readdir-scoped-modules/readdir.js @@ -5,6 +5,7 @@ var path = require ('path') var debug = require ('debuglog') ('rds') module . exports = readdir +readdir.sync = readdirSync function readdir (dir, cb) { fs . readdir (dir, function (er, kids) { @@ -26,6 +27,18 @@ function readdir (dir, cb) { }) } +function readdirSync (dir) { + var kids = fs . readdirSync (dir) + debug ('dir=%j, kids=%j', dir, kids) + var data = readScopesSync (dir, kids) + // Sort for bonus consistency points + data = data . sort (function (a, b) { + return a > b ? 1 : -1 + }) + + return data +} + // Turn [ 'a', '@scope' ] into // ['a', '@scope/foo', '@scope/bar'] function readScopes (root, kids, cb) { @@ -69,3 +82,40 @@ function readScopes (root, kids, cb) { cb (null, kids) } } + +function readScopesSync (root, kids) { + var scopes = kids . filter (function (kid) { + return kid . charAt (0) === '@' + }) + + kids = kids . filter (function (kid) { + return kid . charAt (0) !== '@' + }) + + debug ('scopes=%j', scopes) + + if (scopes . length === 0) + return kids + + var l = scopes . length + scopes . forEach (function (scope) { + var scopedir = path . resolve (root, scope) + debug ('root=%j scope=%j scopedir=%j', root, scope, scopedir) + then (scope, fs . readdirSync (scopedir)) + }) + + function then (scope, scopekids) { + // XXX: Not sure how old this node bug is. Maybe superstition? + scopekids = scopekids . filter (function (scopekid) { + return !(scopekid === '.' || scopekid === '..' || !scopekid) + }) + + kids . push . apply (kids, scopekids . map (function (scopekid) { + return scope + '/' + scopekid + })) + + debug ('scope=%j scopekids=%j kids=%j', scope, scopekids, kids) + } + + return kids +} diff --git a/node_modules/readdir-scoped-modules/test/basic.js b/node_modules/readdir-scoped-modules/test/basic.js deleted file mode 100644 index 715c40d58..000000000 --- a/node_modules/readdir-scoped-modules/test/basic.js +++ /dev/null @@ -1,14 +0,0 @@ -var test = require ('tap') . test -var readdir = require ('../readdir.js') - -test ('basic', function (t) { - // should not get {a,b}/{x,y}, but SHOULD get @org/ and @scope children - var expect = [ '@org/x', '@org/y', '@scope/x', '@scope/y', 'a', 'b' ] - - readdir (__dirname + '/fixtures', function (er, kids) { - if (er) - throw er - t.same(kids, expect) - t.end() - }) -}) diff --git a/node_modules/readdir-scoped-modules/test/fixtures/@org/x/.keep b/node_modules/readdir-scoped-modules/test/fixtures/@org/x/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/@org/x/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/@org/y/.keep b/node_modules/readdir-scoped-modules/test/fixtures/@org/y/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/@org/y/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/@scope/x/.keep b/node_modules/readdir-scoped-modules/test/fixtures/@scope/x/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/@scope/x/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/@scope/y/.keep b/node_modules/readdir-scoped-modules/test/fixtures/@scope/y/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/@scope/y/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/a/x/.keep b/node_modules/readdir-scoped-modules/test/fixtures/a/x/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/a/x/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/a/y/.keep b/node_modules/readdir-scoped-modules/test/fixtures/a/y/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/a/y/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/b/x/.keep b/node_modules/readdir-scoped-modules/test/fixtures/b/x/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/b/x/.keep +++ /dev/null diff --git a/node_modules/readdir-scoped-modules/test/fixtures/b/y/.keep b/node_modules/readdir-scoped-modules/test/fixtures/b/y/.keep deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/readdir-scoped-modules/test/fixtures/b/y/.keep +++ /dev/null |