grunt.file
grunt.file
There are many provided methods for reading and writing files, traversing the filesystem and finding files by matching globbing patterns. Many of these methods are wrappers around built-in Node.js file functionality, but with additional error handling, logging and character encoding normalization.
Note: all file paths are relative to the Gruntfile
unless the current working directory is changed with grunt.file.setBase
or the --base
command-line option.
Character encoding
grunt.file.defaultEncoding
Set this property to change the default encoding used by all grunt.file
methods. Defaults to 'utf8'
. If you do have to change this value, it's recommended that you change it as early as possible inside your Gruntfile.
grunt.file.defaultEncoding = 'utf8';