Skip to content

Commit

Permalink
Problem: copy command at line leaves environment variables out
Browse files Browse the repository at this point in the history
- Implements @Fuco1's idea, using `env` binary to support more shells rather than
  only posix (e.g. fish)

  Posix:     `FLASK_DEBUG=1 FLASK_APP=my_app.py flask run`
  Non-posix: `env FLASK_DEBUG=1 FLASK_APP=my_app.py flask run`

- Adds shut-up test dependency

Solution: add environment variables to the yank command
  • Loading branch information
FrancescElies committed Feb 26, 2018
1 parent a90f917 commit b9ae9e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cask
Expand Up @@ -6,6 +6,7 @@
(development
(depends-on "f")
(depends-on "ecukes")
(depends-on "shut-up")
(depends-on "el-mock")
(depends-on "ert-runner")
(depends-on "ert-async"))
8 changes: 7 additions & 1 deletion prodigy.el
Expand Up @@ -1196,9 +1196,15 @@ started."
"Copy cmd at line."
(interactive)
(let* ((service (prodigy-service-at-pos))
(envs (s-join " "
(-map (lambda (env-var-value)
(s-join "=" env-var-value))
(prodigy-service-env service))))
(envs-string (if (not (s-equals? envs ""))
(concat "env " envs " ")))
(cmd (prodigy-service-command service))
(args (prodigy-service-args service))
(cmd-str (concat cmd " " (s-join " " args))))
(cmd-str (concat envs-string cmd " " (s-join " " args))))
(kill-new cmd-str)
(message "%s" cmd-str)))

Expand Down
19 changes: 19 additions & 0 deletions test/prodigy-test.el
Expand Up @@ -80,6 +80,25 @@
(mock (browse-url "http://localhost:3000/foo"))
(prodigy-browse)))


;;;; prodigy-copy-cmd

(ert-deftest prodigy-copy-cmd-test/multiple-env ()
(with-mock
(stub prodigy-service-at-pos => '(:command "stub-service"
:args ("--stub-arg")
:env (("STUB_ENV_A" "a")
("STUB_ENV_B" "b"))))
(mock (kill-new "env STUB_ENV_A=a STUB_ENV_B=b stub-service --stub-arg"))
(shut-up (prodigy-copy-cmd))))

(ert-deftest prodigy-copy-cmd-test/no-env ()
(with-mock
(stub prodigy-service-at-pos => '(:command "stub-service"
:args ("--stub-arg")))
(mock (kill-new "stub-service --stub-arg"))
(shut-up (prodigy-copy-cmd))))

(provide 'prodigy-api)

;;; prodigy-api.el ends here

0 comments on commit b9ae9e1

Please sign in to comment.