Skip to content

Commit 7572d5f

Browse files
committed
chore: implement PR feedback
1 parent 5f6880f commit 7572d5f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/src/main/java/com/diffplug/spotless/npm/NpmResourceHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import com.diffplug.spotless.ThrowingEx;
3333

3434
final class NpmResourceHelper {
35+
36+
public static final String MD5_STRING_DELIMITER = "@@@";
37+
3538
private NpmResourceHelper() {
3639
// no instance required
3740
}
@@ -143,11 +146,11 @@ static String md5(File file) {
143146

144147
static String md5(String fileContent, String... additionalFileContents) {
145148
Objects.requireNonNull(fileContent, "fileContent must not be null");
146-
Stream<String> additionalFilecontentStream = Stream.concat(
149+
Stream<String> additionalFileContentStream = Stream.concat(
147150
Stream.of(fileContent),
148151
Stream.of(additionalFileContents));
149152
MessageDigest md = ThrowingEx.get(() -> MessageDigest.getInstance("MD5"));
150-
String stringToHash = additionalFilecontentStream.collect(Collectors.joining("@@@"));
153+
String stringToHash = additionalFileContentStream.collect(Collectors.joining(MD5_STRING_DELIMITER));
151154
md.update(stringToHash.getBytes(StandardCharsets.UTF_8));
152155

153156
byte[] digest = md.digest();

lib/src/main/resources/com/diffplug/spotless/npm/common-serve.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// this file will be glued to the top of the specific xy-serve.js file
22
const debug_serve = false; // set to true for debug log output in node process
3-
const gracefulShutdown = require("http-graceful-shutdown");
3+
const shutdownServer = require("http-graceful-shutdown");
44
const express = require("express");
55
const app = express();
66

@@ -48,14 +48,18 @@ var listener = app.listen(0, "127.0.0.1", () => {
4848
}
4949
});
5050
});
51-
const shutdown = gracefulShutdown(listener, {
51+
const shutdown = shutdownServer(listener, {
5252
forceExit: false, // let the event loop clear
5353
finally: () => debugLog("graceful shutdown finished."),
5454
});
5555

5656
app.post("/shutdown", (req, res) => {
5757
res.status(200).send("Shutting down");
5858
setTimeout(async () => {
59-
await shutdown()
59+
try {
60+
await shutdown();
61+
} catch (err) {
62+
console.error("Error during shutdown:", err);
63+
}
6064
}, 200);
6165
});

0 commit comments

Comments
 (0)