From 4576b4c97bc685c9d774018d6b29c918abd7cb8d Mon Sep 17 00:00:00 2001 From: Unitech Date: Thu, 17 May 2018 19:47:49 +0200 Subject: [PATCH] refactor: replace fs-extra with node calls --- lib/API/Startup.js | 7 +++---- lib/God/ActionMethods.js | 3 +-- package.json | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/API/Startup.js b/lib/API/Startup.js index b96877fe8..356197f64 100644 --- a/lib/API/Startup.js +++ b/lib/API/Startup.js @@ -7,7 +7,6 @@ var debug = require('debug')('pm2:cli:startup'); var chalk = require('chalk'); var path = require('path'); var fs = require('fs'); -const fsExtra = require('fs-extra'); var async = require('async'); var exec = require('child_process').exec; var Common = require('../Common.js'); @@ -397,7 +396,7 @@ module.exports = function(CLI) { // Back up dump file try { if (fs.existsSync(cst.DUMP_FILE_PATH)) { - fsExtra.copySync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH); + fs.writeFileSync(cst.DUMP_BACKUP_FILE_PATH, fs.readFileSync(cst.DUMP_FILE_PATH)); } } catch (e) { console.error(e.stack || e); @@ -411,8 +410,8 @@ module.exports = function(CLI) { console.error(e.stack || e); try { // try to backup file - if(fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)) { - fsExtra.copySync(cst.DUMP_BACKUP_FILE_PATH, cst.DUMP_FILE_PATH); + if (fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)) { + fs.writeFileSync(cst.DUMP_FILE_PATH, fs.readFileSync(cst.DUMP_BACKUP_FILE_PATH)); } } catch (e) { // don't keep broken file diff --git a/lib/God/ActionMethods.js b/lib/God/ActionMethods.js index 834b68f38..836655712 100644 --- a/lib/God/ActionMethods.js +++ b/lib/God/ActionMethods.js @@ -12,7 +12,6 @@ */ var fs = require('fs'); -const fsExtra = require('fs-extra'); var path = require('path'); var async = require('async'); var os = require('os'); @@ -165,7 +164,7 @@ module.exports = function(God) { // Back up dump file try { if (fs.existsSync(cst.DUMP_FILE_PATH)) { - fsExtra.copySync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH); + fs.writeFileSync(cst.DUMP_BACKUP_FILE_PATH, fs.readFileSync(cst.DUMP_FILE_PATH)); } } catch (e) { console.error(e.stack || e); diff --git a/package.json b/package.json index 6cb2bf9e0..7e325cc88 100644 --- a/package.json +++ b/package.json @@ -170,7 +170,6 @@ "debug": "^3.1", "eventemitter2": "5.0.1", "fclone": "1.0.11", - "fs-extra": "^5.0.0", "mkdirp": "0.5.1", "moment": "^2.22", "needle": "^2.2.0",