1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/build/replace.js

17 lines
404 B
JavaScript
Raw Normal View History

2017-02-15 13:03:33 +00:00
import { rename } from 'mz/fs'
import { join } from 'path'
2017-02-15 13:03:33 +00:00
export default async function replaceCurrentBuild (dir, buildDir) {
const _dir = join(dir, '.next')
const _buildDir = join(buildDir, '.next')
const oldDir = join(buildDir, '.next.old')
2017-02-15 13:03:33 +00:00
try {
await rename(_dir, oldDir)
} catch (err) {
if (err.code !== 'ENOENT') throw err
}
await rename(_buildDir, _dir)
return oldDir
}