Skip to content

Commit

Permalink
refactor: replace fs-extra with node calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed May 17, 2018
1 parent 53ca18c commit 4576b4c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/API/Startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/God/ActionMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4576b4c

Please sign in to comment.