diff --git a/package.json b/package.json index c687aa18..3160d387 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "loader-utils": "0.2.16", "minimist": "1.2.0", "mkdirp-then": "1.2.0", + "mv": "^2.1.1", "mz": "2.6.0", "path-match": "1.2.4", "pkg-up": "1.0.0", diff --git a/server/build/replace.js b/server/build/replace.js index ba55702e..daf07164 100644 --- a/server/build/replace.js +++ b/server/build/replace.js @@ -1,4 +1,4 @@ -import { rename } from 'mz/fs' +import mv from 'mv' import { join } from 'path' export default async function replaceCurrentBuild (dir, buildDir) { @@ -7,10 +7,15 @@ export default async function replaceCurrentBuild (dir, buildDir) { const oldDir = join(buildDir, '.next.old') try { - await rename(_dir, oldDir) + await move(_dir, oldDir) } catch (err) { if (err.code !== 'ENOENT') throw err } - await rename(_buildDir, _dir) + await move(_buildDir, _dir) return oldDir } + +function move (from, to) { + return new Promise((resolve, reject) => + mv(from, to, err => err ? reject(err) : resolve())) +}