From 82bf28d43f5004227bd49a9f935cc30c63ec1ca0 Mon Sep 17 00:00:00 2001 From: Nithin-SRI Date: Thu, 9 May 2024 12:09:51 -0500 Subject: [PATCH] Fixed Issue #1764 --- lib/grunt/file.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.