Grunt:将文件名插入文件

Grunt: insert filenames into files

使用Grunt.js,我需要读取目录中一系列JavaScript 文件的文件名,并将每个名称的一部分插入到每个文件中。我没有找到允许我执行此操作的 Grunt 任务。

因此,如果我的文件名为 someFileName.js,我希望文件的开头如下所示:

var someFileName = ...

执行此操作的简单方法是什么?

grunt-string-replace 在最近的 1.3.0 版本中似乎有我需要的东西:

Inject src and dest into the callback function when replacement is a function; this allows the replacement function to use the old and/or new file paths/names for further processing