 (defun jetpack-compile ()
   "Complete entrypoint and compile with Jetpack."
   (interactive)
-  (let* ((current-file (or (buffer-file-name) default-directory))
-         (root-dir (locate-dominating-file current-file "jetpack.json")))
+  (let ((root-dir (jetpack--project-root)))
     (if root-dir
         (let* ((default-directory root-dir)
                (json-object-type 'hash-table)

(defun jetpack-compile-file (file)
  "Compile a file using Jetpack and show compilation results."
  (interactive "fJetpack: ")
  (let ((default-directory (locate-dominating-file file "jetpack.json")))
    (compilation-start
     (concat "/usr/bin/npx jetpack " (file-relative-name file))
     'elm-compilation-mode

            (if (string-match-p "\.js$" current-file) current-file))
        jetpack-last-compiled)))

(defun jetpack--project-root (&optional file)
  (let* ((file (or file (buffer-file-name) default-directory)))
    (locate-dominating-file file "jetpack.json")))

(defun jetpack-action (file)
  "Helper function to compile file and save last-compiled."
  (setq jetpack-last-compiled file)
