forked from koding/koding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup
executable file
·51 lines (38 loc) · 1.7 KB
/
cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env coffee
read = require 'read'
colors = require 'colors'
{ exec } = require 'child_process'
has = (arg)-> "--#{arg}" in process.argv
hasYes = has "yes"
includeGo = if has "includeGo" then "" else "-e go"
do cleanup = ->
sure = if hasYes then "" else "-n"
exec "git status",(err,stdout,stderr)->
console.log has "force"
if stdout.indexOf("Untracked files") > -1 and not has("force")
console.log "You have untracked files, they may be files you are working on - "
console.log "if they get DELETED, you get mad. exiting now... (do git status and resolve first or use --force )"
process.exit()
else
exec "git clean -d -f #{sure} -x -e cleanup -e .vagrant -e node_modules -e node_modules_koding #{includeGo}", (err, res)->
if res isnt ''
console.log "\n#{res}".yellow
if not hasYes
console.log "If you are sure to remove these files you can directly run:\n".red
console.log " $ ./cleanup --yes \n".cyan
if not has "includeGo"
console.log "If you want to cleanup GO binaries too, try:\n".red
console.log " $ ./cleanup --includeGo \n".cyan
read
prompt : "Do you want to cleanup these files now? (y/N)"
default : "N"
,
(err, answer)->
if answer in ["y", "Y"]
hasYes = yes # :)
cleanup()
else
console.log "All remaining files removed, it's a new era for you!".green
console.log "Now you need to do './configure' again.\n".yellow
else
console.log "Everything seems fine, nothing to remove.".green