|
@ -1,5 +1,6 @@ |
|
|
var fs = require('fs-extra'); |
|
|
var fs = require('fs-extra'); |
|
|
var shell = require('shelljs'); |
|
|
var shell = require('shelljs'); |
|
|
|
|
|
var beautifyJSON = require("json-beautify"); |
|
|
|
|
|
|
|
|
var EOL = require('os').EOL; // \n if used on Linux, \r\n if used on Windows.
|
|
|
var EOL = require('os').EOL; // \n if used on Linux, \r\n if used on Windows.
|
|
|
|
|
|
|
|
@ -24,17 +25,7 @@ function appendToList(domain, outPort, inPort) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
jsonFile = { |
|
|
jsonFile = {} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var newBlock = { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
/* |
|
|
|
|
|
Object.assign(jsonFile, domain.domBlock) |
|
|
|
|
|
return jsonFile; |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(listFilePath)) { |
|
|
if (fs.existsSync(listFilePath)) { |
|
|
jsonFile = fs.readFileSync(listFilePath); |
|
|
jsonFile = fs.readFileSync(listFilePath); |
|
@ -48,13 +39,12 @@ function appendToList(domain, outPort, inPort) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
jsonFile[domain] = domBlock; |
|
|
jsonFile[domain] = domBlock; |
|
|
jsonFile = JSON.stringify(jsonFile); |
|
|
jsonFile = beautifyJSON(jsonFile, null, 2, 30); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
jsonFile = { |
|
|
jsonFile = {} |
|
|
} |
|
|
|
|
|
jsonFile[domain] = domBlock; |
|
|
jsonFile[domain] = domBlock; |
|
|
jsonFile = JSON.stringify(jsonFile); |
|
|
jsonFile = beautifyJSON(jsonFile); |
|
|
} |
|
|
} |
|
|
fs.writeFileSync(listFilePath, jsonFile); |
|
|
fs.writeFileSync(listFilePath, jsonFile); |
|
|
|
|
|
|
|
|