rmproject
This commit is contained in:
parent
9e6e64cb0e
commit
a67b04ba51
20
bin/rmproject.ts
Normal file
20
bin/rmproject.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Remove a project. Careful! There's no undo.
|
||||||
|
|
||||||
|
import { rmdirSync } from "fs"
|
||||||
|
import { DEFAULT_PROJECT } from "@/config"
|
||||||
|
import { projectDir, projects, projectName } from "@/project"
|
||||||
|
import load from "./load"
|
||||||
|
|
||||||
|
export default function (project: string, confirm = false) {
|
||||||
|
if (!projects().includes(project)) throw `no ${project} project`
|
||||||
|
if (project === DEFAULT_PROJECT) throw `can't delete ${DEFAULT_PROJECT} project`
|
||||||
|
if (!confirm) throw `> Are you POSITIVE?\n> Run again with 'true' at the end:\n\n$ rmproject ${project} true`
|
||||||
|
|
||||||
|
const isCurrent = projectName() === project
|
||||||
|
|
||||||
|
rmdirSync(projectDir(project), { recursive: true })
|
||||||
|
|
||||||
|
if (isCurrent)
|
||||||
|
|
||||||
|
return `${project} deleted`
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user