diff --git a/lib/grunt/file.js b/lib/grunt/file.js index 9619e808..8b115b7c 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -268,7 +268,9 @@ file.write = function(filepath, contents, options) { var nowrite = grunt.option('no-write'); grunt.verbose.write((nowrite ? 'Not actually writing ' : 'Writing ') + filepath + '...'); // Create path, if necessary. - file.mkdir(path.dirname(filepath)); + if (!file.exists(path.dirname(filepath))) { + file.mkdir(path.dirname(filepath)); + } try { // If contents is already a Buffer, don't try to encode it. If no encoding // was specified, use the default.