mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
2e0db62b52
* Fix "EXDEV: cross-device link not permitted" error * Fix lint errors Not sure why standard passes in my dev environment, but hopefully this fixes the CI errors. * Fix logic mistake Wow, my bad :/
22 lines
517 B
JavaScript
22 lines
517 B
JavaScript
import mv from 'mv'
|
|
import { join } from 'path'
|
|
|
|
export default async function replaceCurrentBuild (dir, buildDir) {
|
|
const _dir = join(dir, '.next')
|
|
const _buildDir = join(buildDir, '.next')
|
|
const oldDir = join(buildDir, '.next.old')
|
|
|
|
try {
|
|
await move(_dir, oldDir)
|
|
} catch (err) {
|
|
if (err.code !== 'ENOENT') throw err
|
|
}
|
|
await move(_buildDir, _dir)
|
|
return oldDir
|
|
}
|
|
|
|
function move (from, to) {
|
|
return new Promise((resolve, reject) =>
|
|
mv(from, to, err => err ? reject(err) : resolve()))
|
|
}
|