-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8d88d7
commit c943c54
Showing
3 changed files
with
17 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "Hakit", | ||
"version": "1.0.30", | ||
"version": "1.0.31", | ||
"slug": "hakit", | ||
"init": false, | ||
"ingress": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import { Request, Response } from 'express'; | ||
import { join } from 'path'; | ||
import { existsSync } from 'fs'; | ||
import { rm } from 'fs/promises' | ||
import { APP_DIRECTORY } from '../constants.js'; | ||
import { translateError } from '../helpers/index.js'; | ||
|
||
export async function removeBuildDirectory() { | ||
// remove the directory .next | ||
const buildDir = join(APP_DIRECTORY, 'app', '.next'); | ||
await rm(buildDir, { recursive: true, force: true }); | ||
console.log('.next directory removed successfully'); | ||
} | ||
|
||
|
||
export async function removeBuild(_req: Request, res: Response) { | ||
const buildDir = join(APP_DIRECTORY, 'app', '.next'); | ||
const nextJsBuilt = existsSync(buildDir); | ||
if (nextJsBuilt) { | ||
// remove the directory .next | ||
try { | ||
await rm(buildDir, { recursive: true, force: true }); | ||
console.log('.next directory removed successfully'); | ||
return res.status(200).send('Directory removed successfully'); | ||
} catch (error) { | ||
console.error('Error removing build directory:', translateError(error)); | ||
return res.status(500).send('Error removing build directory'); | ||
} | ||
try { | ||
await removeBuildDirectory(); | ||
console.log('.next directory removed successfully'); | ||
return res.status(200).send('Directory removed successfully'); | ||
} catch (error) { | ||
console.error('Error removing build directory:', translateError(error)); | ||
return res.status(500).send('Error removing build directory'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters