Skip to content

Commit a1dd3e7

Browse files
authored
perf: using async fs APIs (#7)
1 parent 3e9a010 commit a1dd3e7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/util.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ export const resolveHttpsConfig = async (
3434
);
3535

3636
if (fs.existsSync(certPath)) {
37-
const stats = fs.statSync(certPath);
37+
const stats = await fs.promises.stat(certPath);
3838
const timeDiff = Date.now() - stats.mtimeMs;
3939
const daysDiff = timeDiff / (1000 * 60 * 60 * 24);
4040

4141
// Default validity period is 30 days
4242
if (daysDiff < 30) {
43-
const content = fs.readFileSync(certPath, { encoding: 'utf-8' });
43+
const content = await fs.promises.readFile(certPath, {
44+
encoding: 'utf-8',
45+
});
4446
return {
4547
key: content,
4648
cert: content,
@@ -62,7 +64,7 @@ export const resolveHttpsConfig = async (
6264
await ensureDir(options.outputPath);
6365
}
6466

65-
fs.writeFileSync(certPath, content, { encoding: 'utf-8' });
67+
await fs.promises.writeFile(certPath, content, { encoding: 'utf-8' });
6668

6769
return {
6870
key: content,

0 commit comments

Comments
 (0)