 op = (require '../util/optionsParser')
 uploader = (require "../util/upload")
 
+config = {}
+
 die = ()-> process.kill('SIGTERM')
 
-watch = (local, remote, token, ignored)->
-    console.log "Watching", color(local, "white_bg+black") ,"for changes.."
+watch = (token, conf = config)->
+    console.log "Watching", color(conf.local, "white_bg+black") ,"for changes.."
     console.log ""
 
-    watcher = chokidar.watch local,
+    watcher = chokidar.watch conf.local,
         ignored: (item) ->
             ignored_extensions = /\.(less|git|coffee|tmpl|DS_Store)/i
             ignored_directories = /node_modules/i
             ignored_files = /grunt.js|cakefile/i
 
-            ignore = item.match(ignored_extensions) or item.match(ignored_directories) or item.match(ignored_files) or (ignored and items.match(ignored))
+            ignore = item.match(ignored_extensions) or item.match(ignored_directories) or item.match(ignored_files) or (conf.ignored and items.match(conf.ignored))
             # if ignore then console.log item, ignore
             return ignore
 

        persistent: true

    upload = (localPath, stats) ->
        serverPath = localPath.replace(local, '')
        simPath = "#{remote}/#{serverPath}"

        time = process.hrtime()
        uploader.uploadFileAPI localPath, simPath, token, (err, stdout, stderr) ->

                authenicateUser (newtoken)->
                    token = newtoken
                    upload localPath, stats

            else if response.message
                console.error color(response.status_code + ":", "red"), response.message
            else
