Skip to content

Commit 4a1e2b6

Browse files
committed
build(deps): forward-port to new glob v11 API
1 parent f8e6da3 commit 4a1e2b6

File tree

3 files changed

+236
-124
lines changed

3 files changed

+236
-124
lines changed

index.js

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const os = require("os");
66
const path = require("path");
77
const resolve = require("resolve").sync;
88
const spawn = require("child_process").spawn;
9-
const glob = require("glob");
9+
const { globSync } = require("glob");
1010
const async = require("async");
1111

1212
const VERSION = require("./package.json").version;
@@ -82,52 +82,47 @@ function spawnGoogleJavaFormat(args, done, stdio) {
8282
// remove glob from arg list
8383
args = args.filter((arg) => arg.indexOf(GLOB_OPTION) === -1);
8484

85-
glob(filesGlob, function (err, files) {
86-
if (err) {
87-
done(err);
88-
return;
89-
}
90-
91-
// split file array into chunks of 30
92-
let i,
93-
j,
94-
chunks = [],
95-
chunkSize = 30;
96-
97-
for (i = 0, j = files.length; i < j; i += chunkSize) {
98-
chunks.push(files.slice(i, i + chunkSize));
99-
}
100-
101-
// launch a new process for each chunk
102-
async.series(
103-
chunks.map(function (chunk) {
104-
return function (callback) {
105-
const googlejavaFormatProcess = spawn(
106-
nativeBinary,
107-
args.concat(chunk),
108-
{ stdio: stdio }
109-
);
110-
googlejavaFormatProcess.on("close", function (exit) {
111-
if (exit !== 0) callback(errorFromExitCode(exit));
112-
else callback();
113-
});
114-
};
115-
}),
116-
function (err) {
117-
if (err) {
118-
done(err);
119-
return;
120-
}
121-
console.log("\n");
122-
console.log(
123-
`ran google-java-format on ${files.length} ${
124-
files.length === 1 ? "file" : "files"
125-
}`
85+
const files = globSync(filesGlob);
86+
87+
// split file array into chunks of 30
88+
let i,
89+
j,
90+
chunks = [],
91+
chunkSize = 30;
92+
93+
for (i = 0, j = files.length; i < j; i += chunkSize) {
94+
chunks.push(files.slice(i, i + chunkSize));
95+
}
96+
97+
// launch a new process for each chunk
98+
async.series(
99+
chunks.map(function (chunk) {
100+
return function (callback) {
101+
const googlejavaFormatProcess = spawn(
102+
nativeBinary,
103+
args.concat(chunk),
104+
{ stdio: stdio }
126105
);
127-
done();
106+
googlejavaFormatProcess.on("close", function (exit) {
107+
if (exit !== 0) callback(errorFromExitCode(exit));
108+
else callback();
109+
});
110+
};
111+
}),
112+
function (err) {
113+
if (err) {
114+
done(err);
115+
return;
128116
}
129-
);
130-
});
117+
console.log("\n");
118+
console.log(
119+
`ran google-java-format on ${files.length} ${
120+
files.length === 1 ? "file" : "files"
121+
}`
122+
);
123+
done();
124+
}
125+
);
131126
} else {
132127
const googlejavaFormatProcess = spawn(nativeBinary, args, { stdio: stdio });
133128
googlejavaFormatProcess.on("close", function (exit) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"license": "Apache-2.0",
3333
"dependencies": {
3434
"async": "^3.2.6",
35-
"glob": "^8.1.0",
36-
"resolve": "^1.22.10"
35+
"glob": "^11.0.3",
36+
"resolve": "^1.22.11"
3737
},
3838
"devDependencies": {
3939
"np": "^10.2.0"

0 commit comments

Comments
 (0)