Fail is a src file does not exist #15

Closed
ibc opened this Issue Mar 6, 2013 · 12 comments

Comments

Projects
None yet
7 participants

ibc commented Mar 6, 2013

If src is set with a non existing/readable file (or with an array containing at least one non existing/readable file) then the task does not fail nor warns about it.

I'd strongly prefer it to fail, or at least it would be useful a new option "checkSrcFile" (false by default). If set to true then the concat task would fail if any of the files in src does not exist.

This would be useful. I'd normally expect a build to fail or warn if a component is missing but we should use an option so we don't break existing functionality.

ibc commented Apr 8, 2013

I suggest:

  • By default at least warn in the console about missing files.
  • If some new option fail_on_missing is enabled (may be disabled by default) then raise an error.
Owner

shama commented Apr 8, 2013

Set nonull to true and it will warn on missing files. See the source here and the test here.

shama closed this Apr 8, 2013

ibc commented Apr 8, 2013

It works (as setting `nonull=true' warns missing or unreadable files in console) but this feature is no documented at all. Could you please documment it in the README?

ibc commented Apr 8, 2013

Also, shouldn't nonull be in options?

Owner

shama commented Apr 8, 2013

It's not a concat task option. Please see http://gruntjs.com/configuring-tasks#files
I'll make a note in the docs here that you need to set nonull in order to receive warnings about missing files. Thanks!

Thanks for updating the docs.

I know this issue is closed but I have a particular need to have grunt abort if source files are missing. I'm running grunt from TeamCity and need it to either fail, or output a specific message warning format. Aborting would be a more generic solution - no one wants to see TeamCity messages in this plugin.

I've got a quick solution on a fork at https://github.com/Huddle/grunt-contrib-concat/tree/feature/fail-on-missing-file but the problem I have is writing a nodeunit test for it. The problem is that the abort kills the nodeunit task as well. I've tried spawning the concat for that fixure but have no idea how to get that to report back to the nodeunit parent process. If I can get the test in place I'll raise a pull request but don't have the time right now to get into it. Any pointers would be welcome.

@onsip onsip pushed a commit to onsip/SIP.js that referenced this issue Jan 13, 2014

@ibc ibc Add nonull=true in grunt-contrib-concat to warn about possible mising…
…/unreadable files

(see gruntjs/grunt-contrib-concat#15).
72a19a7

ibc commented Sep 28, 2014

I strongly agree. Please, an option to fail if a source file is missing.

plaa commented Jun 17, 2015

I was very surprised that concatenation of missing files during build time does not fail by default. I'm astounded that you cannot even configure it to fail.

We had our build concatenate CSS files, and one of the files went missing. Instead of failing the build as it should, we just got a build with some of our styles missing. This is simply unacceptable for a build. (A warning is in no way sufficient - builds are generated automatically and produce easily 100+ lines of output, no one will notice a warning in the output.)

Does anyone have a workaround for this issue?

qqilihq commented Aug 30, 2015

I would also heavily appreciate a fail-on-null functionality.

worc commented Sep 10, 2015

this continues to be a problem 2 years on (v0.5.1) and should not have been closed. concat does not throw an error or even warn if a file is missing. in essence concat fails to fail. that's completely unacceptable behavior.

integrating concat with build automation or other integration tools is now entirely suspect. no build can truly be green if concat doesn't recognize missing files as a bad state.

Taytay commented Oct 28, 2016

I am currently using the following workaround. I added a filter task to the concat task, as follows:

            filter: function (filepath) {
                if (!grunt.file.exists(filepath)) {
                    grunt.fail.warn('Could not find: ' + filepath);
                } else {
                    return true;
                }
            },
            nonull: true 

Now it fails if there is a non-existent file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment