gpt4 book ai didi

javascript - 使用 Ant 对多个文件运行单个命令

转载 作者:行者123 更新时间:2023-11-29 15:47:30 27 4
gpt4 key购买 nike

我正在尝试使用 ant 将一堆 Handlebars 模板编译成一个编译文件。我有许多文件夹,每个文件夹包含大约 4 个模板,我想将它们全部编译到一个文件中。文件夹如下:

folder01
|- templates
|- f1_01.handlebars
|- f1_02.handlebars
|- f1_03.handlebars
|- f1_04.handlebars
folder02
|- templates
|- f2_01.handlebars
|- f2_02.handlebars
|- f2_03.handlebars
|- f2_04.handlebars
build.xml

我基本上想运行命令:

handlebars **/templates/*.handlebars -f compiled-templates.js

我尝试了以下方法,但它似乎只在输出 js 文件中包含 1 个文件。

<macrodef name="handlebars">
<attribute name="target"/>
<sequential>
<apply executable="${handlebars}" failonerror="false">
<fileset dir="." includes="**/templates/">
<include name="*.handlebars"/>
</fileset>
<arg value="-f compiled-templates.js"/>
</apply>
</sequential>
</macrodef>

此外,奇怪的是,输出文件以空格字符开头,我似乎无法摆脱它。任何帮助将不胜感激。

最佳答案

在 stackoverflow 上进行了大量搜索之后,更重要的是,阅读了文档后,我想出了这个有效的解决方案。

<echo level="info" message="Pre Compiling templates" />
<apply parallel="true" failonerror="true" executable="node">
<arg value="${webclient.dir.build}/node_modules/handlebars/bin/handlebars" />
<srcfile />
<fileset dir="${webclient}/app/templates" includes="**/*.handlebars"/>
<arg line="-f ${webclient}/app/templates/handlebars.templates.js -m -a" />
</apply>

关于javascript - 使用 Ant 对多个文件运行单个命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9671790/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com