From f5e8849098197493b5785dbef50cad14b2827346 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 28 Jun 2019 14:48:01 -0700 Subject: [PATCH] npm-registry-mock@1.2.1 --- .../readdir-scoped-modules/.travis.yml | 7 --- .../readdir-scoped-modules/package.json | 36 ++++++------- .../readdir-scoped-modules/readdir.js | 50 +++++++++++++++++++ .../readdir-scoped-modules/test/basic.js | 14 ------ .../test/fixtures/@org/x/.keep | 0 .../test/fixtures/@org/y/.keep | 0 .../test/fixtures/@scope/x/.keep | 0 .../test/fixtures/@scope/y/.keep | 0 .../test/fixtures/a/x/.keep | 0 .../test/fixtures/a/y/.keep | 0 .../test/fixtures/b/x/.keep | 0 .../test/fixtures/b/y/.keep | 0 package-lock.json | 15 +++--- package.json | 3 +- 14 files changed, 79 insertions(+), 46 deletions(-) delete mode 100644 node_modules/readdir-scoped-modules/.travis.yml delete mode 100644 node_modules/readdir-scoped-modules/test/basic.js delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/@org/x/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/@org/y/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/@scope/x/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/@scope/y/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/a/x/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/a/y/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/b/x/.keep delete mode 100644 node_modules/readdir-scoped-modules/test/fixtures/b/y/.keep diff --git a/node_modules/readdir-scoped-modules/.travis.yml b/node_modules/readdir-scoped-modules/.travis.yml deleted file mode 100644 index e1bcee1acd90c..0000000000000 --- 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 92afa2d9929e8..08e6e67b29a6b 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 efbe5526d8ccf..806d787051852 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 715c40d584b57..0000000000000 --- 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 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 e69de29bb2d1d..0000000000000 diff --git a/package-lock.json b/package-lock.json index 03e3940f30ccb..c9cb0e916e383 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3918,13 +3918,14 @@ } }, "npm-registry-mock": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/npm-registry-mock/-/npm-registry-mock-1.1.0.tgz", - "integrity": "sha1-bkKiQixLK9AqaChfVr5wIiDGRMw=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/npm-registry-mock/-/npm-registry-mock-1.2.1.tgz", + "integrity": "sha512-1d3O7bHSBjMKK21NUiu+x23x0jYRe9imJsWCmuaZx3QYX9PBU32O5hIgUcocq4siRMhsX3DSSBAfBbbXxVt4bA==", "dev": true, "requires": { "hock": "~0.2.5", - "util-extend": "~1.0.1" + "readdir-scoped-modules": "^1.1.0", + "util-extend": "^1.0.3" } }, "npm-run-path": { @@ -4940,9 +4941,9 @@ } }, "readdir-scoped-modules": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz", - "integrity": "sha1-n6+jfShr5dksuuve4DDcm19AZ0c=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz", + "integrity": "sha512-asaikDeqAQg7JifRsZn1NJZXo9E+VwlyCfbkZhwyISinqk5zNS6266HS5kah6P0SaQKGF6SkNnZVHUzHFYxYDw==", "requires": { "debuglog": "^1.0.1", "dezalgo": "^1.0.0", diff --git a/package.json b/package.json index 78553e52515d6..793b45920e507 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "read-package-json": "^2.0.13", "read-package-tree": "^5.2.2", "readable-stream": "^3.3.0", + "readdir-scoped-modules": "^1.1.0", "request": "^2.88.0", "retry": "^0.12.0", "rimraf": "^2.6.3", @@ -273,7 +274,7 @@ "marked": "^0.6.0", "marked-man": "^0.2.1", "npm-registry-couchapp": "^2.7.2", - "npm-registry-mock": "^1.1.0", + "npm-registry-mock": "^1.2.1", "require-inject": "^1.4.4", "sprintf-js": "^1.1.2", "standard": "^11.0.1",