mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
fix: use resolve fallback solve fs problem, not patching
This commit is contained in:
parent
ba4fbbd5c9
commit
bd3cdffcfc
4 changed files with 716 additions and 162 deletions
|
|
@ -1,118 +0,0 @@
|
|||
diff --git a/lib/Graph.js b/lib/Graph.js
|
||||
index cd204a7a9d7225a2a24901cc4220dfcd3d40956e..2f4ced1521b00639105c7e63d6b7fe4a5e83a68f 100644
|
||||
--- a/lib/Graph.js
|
||||
+++ b/lib/Graph.js
|
||||
@@ -11,7 +11,6 @@ exports.mergeResolveTheirs = exports.equivalent = exports.loadFile = exports.loa
|
||||
/* eslint-env browser, node */
|
||||
const events_1 = require("events");
|
||||
const clone = require("clone");
|
||||
-const fs_1 = require("fs");
|
||||
const Platform_1 = require("./Platform");
|
||||
// This class represents an abstract FBP graph containing nodes
|
||||
// connected to each other with edges.
|
||||
@@ -910,35 +909,6 @@ class Graph extends events_1.EventEmitter {
|
||||
});
|
||||
return json;
|
||||
}
|
||||
- save(file, callback) {
|
||||
- let promise;
|
||||
- if (Platform_1.isBrowser()) {
|
||||
- promise = Promise.reject(new Error('Saving graphs not supported on browser'));
|
||||
- }
|
||||
- else {
|
||||
- promise = new Promise((resolve, reject) => {
|
||||
- const json = JSON.stringify(this.toJSON(), null, 4);
|
||||
- let filename = file;
|
||||
- if (!filename.match(/\.json$/)) {
|
||||
- filename = `${file}.json`;
|
||||
- }
|
||||
- fs_1.writeFile(filename, json, 'utf-8', (err) => {
|
||||
- if (err) {
|
||||
- reject(err);
|
||||
- return;
|
||||
- }
|
||||
- resolve(filename);
|
||||
- });
|
||||
- });
|
||||
- }
|
||||
- if (callback) {
|
||||
- promise.then((filename) => {
|
||||
- callback(null, filename);
|
||||
- }, callback);
|
||||
- return;
|
||||
- }
|
||||
- return promise;
|
||||
- }
|
||||
}
|
||||
exports.Graph = Graph;
|
||||
function createGraph(name, options) {
|
||||
@@ -1081,38 +1051,6 @@ function loadHTTP(url, callback) {
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
-function loadFile(file, callback, metadata = {}, caseSensitive = false) {
|
||||
- let ioPromise;
|
||||
- if (Platform_1.isBrowser()) {
|
||||
- // On browser we can try getting the file via AJAX
|
||||
- ioPromise = loadHTTP(file);
|
||||
- }
|
||||
- else {
|
||||
- ioPromise = new Promise((resolve, reject) => {
|
||||
- // Node.js graph file
|
||||
- fs_1.readFile(file, 'utf-8', (err, data) => {
|
||||
- if (err) {
|
||||
- reject(err);
|
||||
- return;
|
||||
- }
|
||||
- resolve(data);
|
||||
- });
|
||||
- });
|
||||
- }
|
||||
- const promise = ioPromise.then((content) => {
|
||||
- if (file.split('.').pop() === 'fbp') {
|
||||
- return loadFBP(content);
|
||||
- }
|
||||
- return loadJSON(content);
|
||||
- });
|
||||
- if (callback) {
|
||||
- promise.then((content) => {
|
||||
- callback(null, content);
|
||||
- }, callback);
|
||||
- }
|
||||
- return promise;
|
||||
-}
|
||||
-exports.loadFile = loadFile;
|
||||
// remove everything in the graph
|
||||
function resetGraph(graph) {
|
||||
// Edges and similar first, to have control over the order
|
||||
diff --git a/lib/Journal.js b/lib/Journal.js
|
||||
index fa1d071dc72417b4b013d6a1ffc9fe829ffb1c43..fbafafb4fc9e62e090b88f3053572cf6f2edd225 100644
|
||||
--- a/lib/Journal.js
|
||||
+++ b/lib/Journal.js
|
||||
@@ -499,26 +499,6 @@ class Journal extends events_1.EventEmitter {
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
- save(file, callback) {
|
||||
- const promise = new Promise((resolve, reject) => {
|
||||
- const json = JSON.stringify(this.toJSON(), null, 4);
|
||||
- const { writeFile } = require('fs');
|
||||
- writeFile(`${file}.json`, json, 'utf-8', (err) => {
|
||||
- if (err) {
|
||||
- reject(err);
|
||||
- return;
|
||||
- }
|
||||
- resolve();
|
||||
- });
|
||||
- });
|
||||
- if (callback) {
|
||||
- promise.then(() => {
|
||||
- callback(null);
|
||||
- }, callback);
|
||||
- return;
|
||||
- }
|
||||
- return promise;
|
||||
- }
|
||||
}
|
||||
exports.Journal = Journal;
|
||||
//# sourceMappingURL=Journal.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue