Skip to content

Commit

Permalink
Merge pull request #3517 from Unitech/polyfill_fs_copy_node4
Browse files Browse the repository at this point in the history
fix: use polyfill module for copySync with node 4.x
  • Loading branch information
wallet77 committed Mar 5, 2018
2 parents 48f81a8 + bc07f43 commit 524f549
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/API/Startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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 @@ -396,7 +397,7 @@ module.exports = function(CLI) {
// Back up dump file
try {
if (fs.existsSync(cst.DUMP_FILE_PATH)) {
fs.copyFileSync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH);
fsExtra.copySync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH);
}
} catch (e) {
console.error(e.stack || e);
Expand All @@ -411,7 +412,7 @@ module.exports = function(CLI) {
try {
// try to backup file
if(fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)) {
fs.copyFileSync(cst.DUMP_BACKUP_FILE_PATH, cst.DUMP_FILE_PATH);
fsExtra.copySync(cst.DUMP_BACKUP_FILE_PATH, cst.DUMP_FILE_PATH);
}
} catch (e) {
// don't keep broken file
Expand Down
5 changes: 3 additions & 2 deletions lib/God/ActionMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

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 @@ -155,7 +156,7 @@ module.exports = function(God) {
// Back up dump file
try {
if (fs.existsSync(cst.DUMP_FILE_PATH)) {
fs.copyFileSync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH);
fsExtra.copySync(cst.DUMP_FILE_PATH, cst.DUMP_BACKUP_FILE_PATH);
}
} catch (e) {
console.error(e.stack || e);
Expand All @@ -169,7 +170,7 @@ module.exports = function(God) {
try {
// try to backup file
if(fs.existsSync(cst.DUMP_BACKUP_FILE_PATH)) {
fs.copyFileSync(cst.DUMP_BACKUP_FILE_PATH, cst.DUMP_FILE_PATH);
fsExtra.copySync(cst.DUMP_BACKUP_FILE_PATH, cst.DUMP_FILE_PATH);
}
} catch (e) {
// don't keep broken file
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"debug": "^3.0",
"eventemitter2": "5.0.1",
"fclone": "1.0.11",
"fs-extra": "^5.0.0",
"mkdirp": "0.5.1",
"moment": "^2.19",
"needle": "^2.2.0",
Expand Down

0 comments on commit 524f549

Please sign in to comment.