Skip to content

Commit

Permalink
don't resolve cmd template until about to be run
Browse files Browse the repository at this point in the history
  • Loading branch information
heinthanth committed May 15, 2022
1 parent bd7bd02 commit 3587f0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->

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

depOption = { ...dep.options }
if typeof dep.passParentOptions == "boolean" and dep.passParentOptions
Expand All @@ -63,18 +63,18 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->
Deno.chdir(usedCwd)
# make main recipe
_commands = currentRecipe.command
commands = (if typeof _commands == "string" then [_commands] else _commands)
.map (cmdOption) ->
try
if typeof cmdOption == "string" then return eta.render(cmdOption, currentOption)
else return {...cmdOption, cmd: eta.render(cmdOption.cmd, currentOption)}
catch err
console.error(
"\nxuerun: oops, something went wrong while reading command.\nError:",
err.message, "\n")
Deno.exit(1)

for cmdOption in commands
for _cmdOption in (if typeof _commands == "string" then [_commands] else _commands)
try
if typeof _cmdOption == "string"
cmdOption = eta.render(_cmdOption, currentOption)
else cmdOption = {..._cmdOption, cmd: eta.render(_cmdOption.cmd, currentOption)}
catch err
console.error(
"\nxuerun: oops, something went wrong while reading command.\nError:",
err.message, "\n")
Deno.exit(1)

# used by eval
opt = currentOption
# don't run if eval when is false
Expand Down
2 changes: 1 addition & 1 deletion src/xuerun.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ programMain = () ->

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

Expand Down

0 comments on commit 3587f0b

Please sign in to comment.