Skip to content

Commit

Permalink
Fix server postbuild script
Browse files Browse the repository at this point in the history
  • Loading branch information
ba1uev committed Mar 24, 2024
1 parent 59fcf02 commit f5fbf22
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/server.postbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ import { join } from 'path'
*/

const cwd = process.cwd()
const originalDistPath = join(cwd, 'dist_server')
const tempSrcPath = join(cwd, 'src_temp')
const distPath = join(cwd, 'dist_server')
const distSrcPath = join(distPath, 'src')
const tempDistSrcPath = join(cwd, 'src_temp')

// there are no custom modules in `config/modules`
if (!fs.existsSync(join(distPath, 'config'))) {
// delete `dist_server/src` if present (previous build output)
if (fs.existsSync(distSrcPath)) {
fs.rmSync(distSrcPath, { recursive: true })
}

if (!fs.existsSync(join(originalDistPath, 'src'))) {
// rename `dist_server` to `src_temp`
fs.renameSync(originalDistPath, tempSrcPath)
fs.renameSync(distPath, tempDistSrcPath)

// create new empty folder `dist_server`
fs.mkdirSync(originalDistPath)
fs.mkdirSync(distPath)

// rename `src_temp` to `dist_server/src`
fs.renameSync(tempSrcPath, join(originalDistPath, 'src'))
fs.renameSync(tempDistSrcPath, join(distPath, 'src'))
}

0 comments on commit f5fbf22

Please sign in to comment.