Skip to content

Commit

Permalink
Limit exec-dir state setting to the context directive case. #184
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-factual committed Sep 15, 2015
1 parent 2072cfe commit 0e1b2be
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/drake/parser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,13 @@
(dissoc prod :vars)))

(defn- attach-exec-dir
[prod exec-dir]
(update-in prod [:steps]
(fn [steps]
(mapv #(assoc % :exec-dir exec-dir) steps))))
[prod file-path]
(let [exec-dir (dfs/get-directory-path file-path)]
(-> prod
(assoc :exec-dir exec-dir)
(update-in [:steps]
(fn [steps]
(mapv #(assoc % :exec-dir exec-dir) steps))))))

(def ^:const ^:private directive-include "include")
(def ^:const ^:private directive-call "call")
Expand All @@ -687,17 +690,15 @@
base (add-path-sep-suffix raw-base)
;; Need to use fs/file here to honor cwd
^String tokens (slurp (fs/file file-path))
exec-dir (when (= directive directive-context) (dfs/get-directory-path file-path))
prod (parse-state
(assoc (make-state
(ensure-final-newline tokens)
vars methods 0 0)
:exec-dir exec-dir
:file-path file-path))]
(condp = directive
directive-include prod ;call-or-include line will merge vars+methods from prod into parent's vars
directive-call (dissoc prod :vars :methods) ;but vars+methods from %call should not affect parent
directive-context (attach-exec-dir prod exec-dir)))))
directive-context (attach-exec-dir prod file-path)))))

(def call-or-include-line
"input: directive to call/include another Drake workflow. ie.,
Expand Down

0 comments on commit 0e1b2be

Please sign in to comment.