From f2881a3137e5edcad9fd38213c7a722f74460577 Mon Sep 17 00:00:00 2001 From: younglei Date: Tue, 14 Jun 2022 20:36:52 +0800 Subject: [PATCH] add samples/node-api.ts --- src/sample/node-api.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/sample/node-api.ts diff --git a/src/sample/node-api.ts b/src/sample/node-api.ts new file mode 100644 index 0000000..8668059 --- /dev/null +++ b/src/sample/node-api.ts @@ -0,0 +1,14 @@ +import { lstat } from 'fs/promises' +import { cwd } from 'process' +import { ipcRenderer } from 'electron' + +// Usage of ipcRenderer.on +ipcRenderer.on('main-process-message', (_event, ...args) => { + console.log('[Receive Main-process message]:', ...args) +}) + +lstat(cwd()).then(stats => { + console.log('[fs.lstat]', stats) +}).catch(err => { + console.error(err) +})