Przeglądaj źródła

Warn if node cannot access filesystem

master
Massimo 5 lat temu
rodzic
commit
60f07d8edd
3 zmienionych plików z 13 dodań i 4 usunięć
  1. +4
    -0
      CHANGELOG.md
  2. +8
    -3
      boolean-logic-ultimate/BooleanLogicUltimate.js
  3. +1
    -1
      package.json

+ 4
- 0
CHANGELOG.md Wyświetl plik

@@ -1,5 +1,9 @@
# node-red-contrib-boolean-logic-ultimate
<p>
<b>Version 0.0.5</b><br/>
- Bypass persistency if node-red user hasn't permissions to write to the filesystem.<br/>
</p>
<p>
<b>Version 0.0.4</b><br/>
- Fixed conflict issue if you have the old boolean logic installed<br/>
</p>

+ 8
- 3
boolean-logic-ultimate/BooleanLogicUltimate.js Wyświetl plik

@@ -24,7 +24,7 @@ module.exports = function(RED) {
node.status({fill: "blue",shape: "ring",text: "Loaded persistent states (" + Object.keys(node.state).length + " total)."});
}
} catch (error) {
node.status({fill: "grey",shape: "ring",text: "No persistent states"});
node.status({fill: "grey",shape: "ring",text: "No persistent states: " + error});
}
} else {
@@ -45,8 +45,13 @@ module.exports = function(RED) {

// Sabe the state array to a perisistent file
if (this.config.persist == true) {
if (!fs.existsSync("states")) fs.mkdirSync("states");
fs.writeFileSync("states/" + node.id.toString(),JSON.stringify(state));
try {
if (!fs.existsSync("states")) fs.mkdirSync("states");
fs.writeFileSync("states/" + node.id.toString(),JSON.stringify(state));
} catch (error) {
node.status({fill: "red",shape: "dot",text: "Node cannot write to filesystem: " + error});
}
}
// Do we have as many inputs as we expect?

+ 1
- 1
package.json Wyświetl plik

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "0.0.4",
"version": "0.0.5",
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more",
"author": "Supergiovane (https://github.com/Supergiovane)",
"dependencies": {

Ładowanie…
Anuluj
Zapisz