From 51bee445de6239e74f16b4382d6e3a653190d92e Mon Sep 17 00:00:00 2001 From: guox191 Date: Mon, 25 Mar 2019 13:45:21 +0800 Subject: [PATCH] fix fs.writeFile in node 10+ --- CHANGELOG | 3 +++ lib/recorder.js | 10 +++++----- package.json | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b0561c6..6e3005f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +25 March 2019: AnyProxy 3.10.5: + * add callback parameter in `fs.writeFile` which is required in Node.js 10.0.0+ + 26 Feb 2016: AnyProxy 3.10.4: * let users assign the port for web socket in AnyProxy cli diff --git a/lib/recorder.js b/lib/recorder.js index 9917163..9bd08b1 100644 --- a/lib/recorder.js +++ b/lib/recorder.js @@ -1,6 +1,6 @@ //start recording and share a list when required var zlib = require('zlib'), - Datastore = require('nedb'), + Datastore = require('nedb'), util = require("util"), path = require("path"), fs = require("fs"), @@ -31,17 +31,17 @@ function Recorder(option){ logUtil.printLog("db file : " + option.filename); }catch(e){ - logUtil.printLog(e, logUtil.T_ERR); + logUtil.printLog(e, logUtil.T_ERR); logUtil.printLog("Failed to load on-disk db file. Will use in-meomory db instead.", logUtil.T_ERR); db = new Datastore(); } - + }else{ //in-memory db db = new Datastore(); } - self.recordBodyMap = []; // id - body + self.recordBodyMap = []; // id - body self.emitUpdate = function(id,info){ if(info){ @@ -100,7 +100,7 @@ function Recorder(option){ //add to body map //ignore image data var bodyFile = path.join(cachePath,BODY_FILE_PRFIX + id); - fs.writeFile(bodyFile, info.resBody); + fs.writeFile(bodyFile, info.resBody, function() {}); }; self.getBody = function(id,cb){ diff --git a/package.json b/package.json index 771a202..5381cd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "3.10.4", + "version": "3.10.5", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": {