Skip to content

Commit 3587f0b

Browse files
committed
don't resolve cmd template until about to be run
1 parent bd7bd02 commit 3587f0b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/core.coffee

+12-12
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->
3939

4040
for dep in dependencies
4141
# won't pass options
42-
if typeof dep == "string" then await runRecipe(rc, dep, {}, recon, true); break
42+
if typeof dep == "string" then await runRecipe(rc, dep, {}, recon, true); continue
4343

4444
depOption = { ...dep.options }
4545
if typeof dep.passParentOptions == "boolean" and dep.passParentOptions
@@ -63,18 +63,18 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->
6363
Deno.chdir(usedCwd)
6464
# make main recipe
6565
_commands = currentRecipe.command
66-
commands = (if typeof _commands == "string" then [_commands] else _commands)
67-
.map (cmdOption) ->
68-
try
69-
if typeof cmdOption == "string" then return eta.render(cmdOption, currentOption)
70-
else return {...cmdOption, cmd: eta.render(cmdOption.cmd, currentOption)}
71-
catch err
72-
console.error(
73-
"\nxuerun: oops, something went wrong while reading command.\nError:",
74-
err.message, "\n")
75-
Deno.exit(1)
7666

77-
for cmdOption in commands
67+
for _cmdOption in (if typeof _commands == "string" then [_commands] else _commands)
68+
try
69+
if typeof _cmdOption == "string"
70+
cmdOption = eta.render(_cmdOption, currentOption)
71+
else cmdOption = {..._cmdOption, cmd: eta.render(_cmdOption.cmd, currentOption)}
72+
catch err
73+
console.error(
74+
"\nxuerun: oops, something went wrong while reading command.\nError:",
75+
err.message, "\n")
76+
Deno.exit(1)
77+
7878
# used by eval
7979
opt = currentOption
8080
# don't run if eval when is false

src/xuerun.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ programMain = () ->
9292

9393
if recipes.length == 0
9494
if xueRunRc.hasOwnProperty("all")
95-
return runRecipe(xueRunRc, null, recipes, userOption)
95+
return runRecipe(xueRunRc, "all", options, recon, !1)
9696
else console.error("\nxuerun: oops, no recipe given, nothing to do!\n"); Deno.exit(1)
9797
recipes.forEach (recipe) -> await runRecipe(xueRunRc, recipe, options, recon, !1)
9898

0 commit comments

Comments
 (0)