From 1a18501a34c7f9bc6f1c0b84dbcf9a483f4acf27 Mon Sep 17 00:00:00 2001 From: NEMO Date: Wed, 6 Apr 2022 14:38:36 +0800 Subject: [PATCH] feat: use fs/promise instead fs promise instead fs --- packages/renderer/src/samples/node-api.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/renderer/src/samples/node-api.ts b/packages/renderer/src/samples/node-api.ts index 0a1d7ce..8668059 100644 --- a/packages/renderer/src/samples/node-api.ts +++ b/packages/renderer/src/samples/node-api.ts @@ -1,4 +1,4 @@ -import { lstat } from 'fs' +import { lstat } from 'fs/promises' import { cwd } from 'process' import { ipcRenderer } from 'electron' @@ -7,10 +7,8 @@ ipcRenderer.on('main-process-message', (_event, ...args) => { console.log('[Receive Main-process message]:', ...args) }) -lstat(cwd(), (err, stats) => { - if (err) { - console.log(err) - } else { - console.log('[fs.lstat]', stats) - } +lstat(cwd()).then(stats => { + console.log('[fs.lstat]', stats) +}).catch(err => { + console.error(err) })