gruntjs / grunt-contrib-concat

Concatenate files.
http://gruntjs.com/
MIT License
812 stars 170 forks source link

Optional: Don't create an empty file #157

Open Ulrikop opened 8 years ago

Ulrikop commented 8 years ago

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.

Lo5t commented 8 years ago

+1

abelkius commented 8 years ago

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

tkambler commented 8 years ago

I believe this PR solves this problem.

abelkius commented 8 years ago

@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.

tkambler commented 8 years ago

Ah, nevermind then.

dennisfrank commented 8 years ago

Yep. That would be useful. +1

toptalo commented 7 years ago

:+1: