diff --git a/package.json b/package.json index 199cc98..1430ce8 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "webpack-shell-plugin": "^0.4.2" }, "dependencies": { - "bluebird": "^3.4.6" + "bluebird": "^3.4.6", + "fs-extra": "^1.0.0" } } diff --git a/src/lib/sudoer.js b/src/lib/sudoer.js index 964d10c..b2162eb 100644 --- a/src/lib/sudoer.js +++ b/src/lib/sudoer.js @@ -3,6 +3,8 @@ import {watchFile, unwatchFile, unlink, createReadStream, createWriteStream} fro import {normalize, join, dirname} from 'path'; import {createHash} from 'crypto'; +import {copy} from 'fs-extra'; + import {readFile, writeFile, exec, spawn, mkdir, stat} from '~/lib/utils'; let {platform, env} = process; @@ -61,17 +63,15 @@ class SudoerUnix extends Sudoer { if (!this.options.name) { this.options.name = 'Electron'; } } - async copy(source, target) { - return new Promise(async (resolve, reject) => { - source = this.escapeDoubleQuotes(normalize(source)); - target = this.escapeDoubleQuotes(normalize(target)); - try { - let result = await exec(`/bin/cp -R -p "${source}" "${target}"`); - resolve(result); - } - catch (err) { - reject(err); - } + copy(source, target) { + return new Promise((resolve, reject) => { + copy(source, target, (error) => { + if (error) { + reject(error); + } else { + resolve(); + } + }) }); }