Skip to content

Commit 7f66bd2

Browse files
committed
writefile
1 parent 611361f commit 7f66bd2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/scripts/npm-dependencies.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ define("google-charts", [], function() { return window.google || { info: "Google
5050

5151
var fsWrapper = {
5252
fs: {
53+
writeFile: async function(path, buffer, callback) {
54+
if(!window.MESSAGES.sendRpc) { throw new Error("Cannot writeFile on the web"); }
55+
else {
56+
try {
57+
const result = await window.MESSAGES.sendRpc('fs', 'writeFile', [path, buffer]);
58+
return callback(undefined, result);
59+
}
60+
catch(e) {
61+
return callback(e);
62+
}
63+
}
64+
},
5365
readFile: async function(path, opts, callback) {
5466
if(!window.MESSAGES.sendRpc) { throw new Error("Cannot readFile on the web"); }
5567
else {

0 commit comments

Comments
 (0)