1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Made fs functions work again in cli

This commit is contained in:
Laurent Cozic
2017-07-05 22:52:31 +01:00
parent 8adb5a71c5
commit a81fe24368
5 changed files with 48 additions and 5 deletions

View File

@ -15,6 +15,11 @@ class Resource extends BaseItem {
return BaseModel.TYPE_RESOURCE;
}
static fsDriver() {
if (!Resource.fsDriver_) Resource.fsDriver_ = new FsDriverDummy();
return Resource.fsDriver_;
}
static async serialize(item, type = null, shownKeys = null) {
let fieldNames = this.fieldNames();
fieldNames.push('type_');
@ -32,15 +37,15 @@ class Resource extends BaseItem {
return filename(path);
}
// RNFIX: Temporary disabled for React Native
static content(resource) {
return this.fsDriver().readFile(this.fullPath(resource));
// // TODO: node-only, and should probably be done with streams
// const fs = require('fs-extra');
// return fs.readFile(this.fullPath(resource));
}
static setContent(resource, content) {
return this.fsDriver().writeBinaryFile(this.fullPath(resource), content);
// // TODO: node-only, and should probably be done with streams
// const fs = require('fs-extra');
// let buffer = new Buffer(content);