grunt-contrib-concat icon indicating copy to clipboard operation
grunt-contrib-concat copied to clipboard

Optional: Don't create an empty file

Open Ulrikop opened this issue 8 years ago • 7 comments

Hi, I've got the issue, that the conncat task creats a file, although no source file was found. At my case, I want to prevent that.

I looked for an option to disable that feature. I haven't found one. But I found the request #36 from 2013. akhoury asked for the createEmptyFiles option but no one answered. Since I am not sure if the idea was lost because the issue has already been closed, I create a new one to ask for it.

Do you can offer an option like createEmptyFiles: true/false?

To implement it, you must only do that change on line 114 at concat.js:

if (!options.createEmptyFiles &&/^\s*$/.test(src)) {
  grunt.verbose.write('No content available.')
}
else {
  grunt.file.write(f.dest, src);
  grunt.verbose.write('File ' + chalk.cyan(f.dest) + ' created.');
}

Thank you.

Ulrikop avatar Apr 05 '16 13:04 Ulrikop

+1

Lo5t avatar Apr 08 '16 19:04 Lo5t

+ 1 @Ulrikop maybe you can create a pull request for this issue?

abelkius avatar Apr 14 '16 14:04 abelkius

I believe this PR solves this problem.

tkambler avatar Jun 01 '16 16:06 tkambler

@tkambler not exactly, if I understood correctly the PR you are talking about just warn or throws an error if the source file is empty.

The problem described here is: not to create an empty file (if no src files supplied or they are empty), but also not to throw the error which would break the task.

abelkius avatar Jun 02 '16 11:06 abelkius

Ah, nevermind then.

tkambler avatar Jun 02 '16 14:06 tkambler

Yep. That would be useful. +1

dennisfrank avatar Sep 19 '16 13:09 dennisfrank

:+1:

toptalo avatar Oct 19 '16 09:10 toptalo