From: =?utf-8?q?Bastien_Roucari=C3=A8s?= Date: Wed, 19 Nov 2025 16:38:45 +0100 Subject: Port to glob10 forwarded: not-needed --- lib/read-json.js | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/lib/read-json.js b/lib/read-json.js index c55eca3..537971e 100644 --- a/lib/read-json.js +++ b/lib/read-json.js @@ -2,7 +2,8 @@ var fs = require('fs') var path = require('path') -var glob = require('glob') +const { glob } = require('glob') + var normalizeData = require('normalize-package-data') var safeJSON = require('json-parse-even-better-errors') var util = require('util') @@ -218,15 +219,11 @@ function gypfile (file, data, cb) { return cb(null, data) } - glob('*.gyp', { cwd: dir }, function (er, files) { - if (er) { - return cb(er) - } - if (data.gypfile === false) { + if (data.gypfile === false) { return cb(null, data) - } - gypfile_(file, data, files, cb) - }) + } + + glob('*.gyp', { cwd: dir }).then(files => gypfile_(file, data, files, cb)).catch(err => cb(err)) } function gypfile_ (file, data, files, cb) { @@ -246,12 +243,7 @@ function serverjs (file, data, cb) { if (s.start) { return cb(null, data) } - glob('server.js', { cwd: dir }, function (er, files) { - if (er) { - return cb(er) - } - serverjs_(file, data, files, cb) - }) + glob('server.js', { cwd: dir }).then(files => serverjs_(file, data, files, cb)).catch(err => cb(err)) } function serverjs_ (file, data, files, cb) { @@ -294,10 +286,9 @@ function readme (file, data, cb) { } var dir = path.dirname(file) var globOpts = { cwd: dir, nocase: true, mark: true } - glob('{README,README.*}', globOpts, function (er, files) { - if (er) { - return cb(er) - } + + glob('{README,README.*}', globOpts) + .then(files => { // don't accept directories. files = files.filter(function (filtered) { return !filtered.match(/\/$/) @@ -309,6 +300,7 @@ function readme (file, data, cb) { var rm = path.resolve(dir, fn) readme_(file, data, rm, cb) }) + .catch(err => cb(err)) } function preferMarkdownReadme (files) { @@ -346,15 +338,13 @@ function mans (file, data, cb) { } const dirname = path.dirname(file) cwd = path.resolve(path.dirname(file), cwd) - glob('**/*.[0-9]', { cwd }, function (er, mansGlob) { - if (er) { - return cb(er) - } + glob('**/*.[0-9]', { cwd }).then(mansGlob => { data.man = mansGlob.map(man => path.relative(dirname, path.join(cwd, man)).split(path.sep).join('/') ) return cb(null, data) - }) + }) + .catch(err => cb(err)) } function bins (file, data, cb) { @@ -366,12 +356,7 @@ function bins (file, data, cb) { } m = path.resolve(path.dirname(file), m) - glob('**', { cwd: m }, function (er, binsGlob) { - if (er) { - return cb(er) - } - bins_(file, data, binsGlob, cb) - }) + glob('**', { cwd: m }).then(binsGlob => bins_(file, data, binsGlob, cb)).catch(err => cb(err)) } function bins_ (file, data, binsGlob, cb) {