roger
roger

Reputation: 9893

grunt glob file with regex?

I want to read a file with grunt like this:

grunt.file.read(filepath [, options])

but my filepath is a regex:

src/dist/res/js/*.index.js

so I want to find all file end with .index.js, then read it.

Upvotes: 0

Views: 99

Answers (1)

uladzimir
uladzimir

Reputation: 5689

Grunt mostly is a tool with declarative configs, so if you need to read a sequence of files, you're probably doing something wrong.

Anyway your task can be implemented with next snippet

grunt.file.expand('src/dist/res/js/*.index.js').forEach((filePath) => {
    console.log(grunt.file.read(filePath))
})

Upvotes: 1

Related Questions