1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
From: =?utf-8?q?Bastien_Roucari=C3=A8s?= <rouca@debian.org>
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) {
|