1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fixes to fs promises so that electron version runs

This commit is contained in:
Dave Conway-Jones 2021-09-10 08:33:07 +01:00
parent 17f9829498
commit bbf066f030
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
**/ **/
var fs = require('fs-extra'); var fs = require('fs');
var fspath = require('path'); var fspath = require('path');
var runtime; var runtime;
@ -25,7 +25,7 @@ var exampleFlows = null;
async function getFlowsFromPath(path) { async function getFlowsFromPath(path) {
var result = {}; var result = {};
var validFiles = []; var validFiles = [];
return fs.readdir(path).then(files => { return fs.promises.readdir(path).then(files => {
var promises = []; var promises = [];
if (files) { if (files) {
files.forEach(function(file) { files.forEach(function(file) {

View File

@ -23,7 +23,7 @@
var i18n = require("i18next"); var i18n = require("i18next");
var path = require("path"); var path = require("path");
var fs = require("fs-extra"); var fs = require("fs");
var defaultLang = "en-US"; var defaultLang = "en-US";
@ -50,7 +50,7 @@ async function registerMessageCatalog(namespace,dir,file) {
return initPromise.then(function() { return initPromise.then(function() {
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
resourceMap[namespace] = { basedir:dir, file:file, lngs: []}; resourceMap[namespace] = { basedir:dir, file:file, lngs: []};
fs.readdir(dir,function(err, files) { fs.promises.readdir(dir,function(err, files) {
if (err) { if (err) {
resolve(); resolve();
} else { } else {
@ -89,7 +89,7 @@ async function readFile(lng, ns) {
return resourceCache[ns][lng]; return resourceCache[ns][lng];
} else if (resourceMap[ns]) { } else if (resourceMap[ns]) {
const file = path.join(resourceMap[ns].basedir, lng, resourceMap[ns].file); const file = path.join(resourceMap[ns].basedir, lng, resourceMap[ns].file);
const content = await fs.readFile(file, "utf8"); const content = await fs.promises.readFile(file, "utf8");
resourceCache[ns] = resourceCache[ns] || {}; resourceCache[ns] = resourceCache[ns] || {};
resourceCache[ns][lng] = JSON.parse(content.replace(/^\uFEFF/, '')); resourceCache[ns][lng] = JSON.parse(content.replace(/^\uFEFF/, ''));
var baseLng = lng.split('-')[0]; var baseLng = lng.split('-')[0];