rdesktop
filip mertens 1 year ago
parent ee4b672de3
commit 78d3247725
  1. 26
      apps/1test/src/electron/fsPlugin.ts
  2. 6
      apps/1test/src/renderer.ts

@ -1,8 +1,9 @@
import { PluginClient } from "@remixproject/plugin"; import { PluginClient } from "@remixproject/plugin";
import { createClient } from "./electronPluginClient" import { createClient } from "./electronPluginClient"
import { Engine, PluginManager, Plugin } from '@remixproject/engine'; import { Engine, PluginManager, Plugin } from '@remixproject/engine';
import fs from 'fs' import fs from 'fs/promises'
import { existsSync } from "fs-extra"; import { Stats } from "fs";
const profile = { const profile = {
displayName: 'fs', displayName: 'fs',
@ -34,39 +35,36 @@ class FSPluginClient extends PluginClient {
async readdir(path: string): Promise<string[]> { async readdir(path: string): Promise<string[]> {
// call node fs.readdir // call node fs.readdir
return fs.readdirSync(path) return fs.readdir(path)
} }
async readFile(path: string): Promise<string> { async readFile(path: string): Promise<string> {
return fs.readFileSync(path, 'utf8') return fs.readFile(path, 'utf8')
} }
async writeFile(path: string, content: string): Promise<void> { async writeFile(path: string, content: string): Promise<void> {
return fs.writeFileSync(path, content, 'utf8') return fs.writeFile(path, content, 'utf8')
} }
async mkdir(path: string): Promise<void> { async mkdir(path: string): Promise<void> {
return fs.mkdirSync(path) return fs.mkdir(path)
} }
async rmdir(path: string): Promise<void> { async rmdir(path: string): Promise<void> {
return fs.rmdirSync(path) return fs.rmdir(path)
} }
async unlink(path: string): Promise<void> { async unlink(path: string): Promise<void> {
return fs.unlinkSync(path) return fs.unlink(path)
} }
async rename(oldPath: string, newPath: string): Promise<void> { async rename(oldPath: string, newPath: string): Promise<void> {
return fs.renameSync(oldPath, newPath) return fs.rename(oldPath, newPath)
} }
async stat(path: string): Promise<fs.Stats> { async stat(path: string): Promise<Stats> {
return fs.statSync(path) return fs.stat(path)
} }
async exists(path: string): Promise<boolean> {
return existsSync(path)
}
} }

@ -13,12 +13,12 @@ const git = new gitPlugin()
engine.register(appManager) engine.register(appManager)
engine.register(fs) engine.register(fs)
engine.register(git) engine.register(git)
//appManager.activatePlugin('fs') appManager.activatePlugin('fs')
appManager.activatePlugin('git') appManager.activatePlugin('git')
setTimeout(async () => { setTimeout(async () => {
//const files = await appManager.call('fs', 'readdir', './') const files = await appManager.call('fs', 'readdir', './')
//console.log('files', files) console.log('files', files)
const log = await appManager.call('git', 'log', './') const log = await appManager.call('git', 'log', './')
console.log('log', log) console.log('log', log)
}, 5000) }, 5000)

Loading…
Cancel
Save