add samples/node-api.ts

This commit is contained in:
younglei 2022-06-14 20:36:52 +08:00
parent b2b3a5d63c
commit f2881a3137

14
src/sample/node-api.ts Normal file
View File

@ -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)
})