diff --git a/red/storage/localfilesystem.js b/red/storage/localfilesystem.js index e3ff42eb7..c8cabb569 100644 --- a/red/storage/localfilesystem.js +++ b/red/storage/localfilesystem.js @@ -181,7 +181,16 @@ var localfilesystem = { if (fs.existsSync(flowsFullPath)) { fs.renameSync(flowsFullPath,flowsPrev); } - return nodeFn.call(fs.writeFile, flowsFullPath, JSON.stringify(flows)); + + var flowData; + + if (settings.flowFilePretty) { + flowData = JSON.stringify(flows,null,4); + } else { + flowData = JSON.stringify(flows); + } + + return nodeFn.call(fs.writeFile, flowsFullPath, flowData); }, getCredentials: function() { @@ -207,7 +216,14 @@ var localfilesystem = { }, saveCredentials: function(credentials) { - return nodeFn.call(fs.writeFile, credentialsFile, JSON.stringify(credentials)) + var credentialData; + if (settings.flowFilePretty) { + credentialData = JSON.stringify(credentials,null,4); + } else { + credentialData = JSON.stringify(credentials); + } + + return nodeFn.call(fs.writeFile, credentialsFile, credentialData) }, getAllFlows: function() { diff --git a/settings.js b/settings.js index 20b7c10a4..0678a26c5 100644 --- a/settings.js +++ b/settings.js @@ -41,6 +41,10 @@ module.exports = { // The file containing the flows. If not set, it defaults to flows_.json //flowFile: 'flows.json', + // To enabled pretty-printing of the flow within the flow file, set the following + // property to true: + //flowFilePretty: true, + // By default, all user data is stored in the Node-RED install directory. To // use a different location, the following property can be used //userDir: '/home/nol/.node-red/',