             }
 
             do {
-                try run("chmod +x \(name)")
-                try run("mv \(name) \(directory)")
-            } catch {
-                print("Trying with sudo...")
-                do {
-                    try run("sudo mv \(name) \(directory)")
-                } catch {
-                    fail("Could not move Vapor CLI to install location.")
-                }
-            }
-
-            do {
-                try run("rm \(source)")
+                try SelfCommands.install(from: name, to: target)
+            } catch {
+                fail("Could not install compiled binary at '\(target)'")
+            }
+
+            do {
+                try run("rm \(tmp)")
             } catch {
 
             }

// MARK: Self

extension SelfCommands {
    struct Install: Command {
        static let id = "install"

        static func execute(with args: [String], in directory: String) {
            do {
                try run("mv \(directory) /usr/local/bin/vapor")
                print("Vapor CLI installed.")
            } catch {
                print("Trying with sudo.")
                do {
                    try run("sudo mv \(directory) /usr/local/bin/vapor")
                    print("Vapor CLI installed.")
                } catch {
                    fail("Could not move Vapor CLI to install location.")
                }
            }
        }

        static var help: [String] {
            return [
                "Moves the CLI into the bin so",
                "that it is available in the PATH"
            ]
        }
    }
}

extension SelfCommands {

            print("Compiling...")

            let name = "vapor-cli.tmp"
            let compile = "swiftc \(tmp) -o \(name)"
            #if os(OSX)
                let cmd = "env SDKROOT=$(xcrun -show-sdk-path -sdk macosx) \(compile)"
            #else
