Skip to content

Commit

Permalink
Remove backupDir before copy to it
Browse files Browse the repository at this point in the history
`copy` on Mac OS X throws an error "Cannot copy 'Versions/Current/nwjs Framework' to a subdirectory of itself, 'Versions/Current/nwjs Framework'" if `backupDir` already exists from the previous backup.

And in any case it is more clean way.
  • Loading branch information
peter23 committed Mar 11, 2019
1 parent 0c096f2 commit 2c69ad3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/Strategy/AppSwap.js
@@ -1,6 +1,6 @@
const { join } = require( "path" ),
fs = require( "fs-extra" ),
{ launch, copy } = require( "../utils" ),
{ launch, copy, remove } = require( "../utils" ),
{ swapFactory, IS_OSX } = require( "../env" );


Expand Down Expand Up @@ -51,6 +51,9 @@ const { join } = require( "path" ),
async function swap(){
const { executable, backupDir, execDir, updateDir, logPath } = this.options,
log = fs.openSync( logPath, "a" );
if (fs.existsSync( backupDir )) {
await remove( backupDir );
}
if ( IS_OSX ) {
await copy( join( execDir, executable ), backupDir, log );
await copy( updateDir, execDir, log );
Expand Down

0 comments on commit 2c69ad3

Please sign in to comment.