Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a 'nonull' file option that also fails on missing files #1105

Open
vladikoff opened this issue Mar 29, 2014 · 12 comments
Open

Need a 'nonull' file option that also fails on missing files #1105

vladikoff opened this issue Mar 29, 2014 · 12 comments
Labels
Milestone

Comments

@vladikoff
Copy link
Member

Something like nonullFail:

 bar: {
      files: [
        // if any files are missing, fail the build
        {src: ['src/bb.js', 'src/bbb.js'], dest: 'dest/b/', nonullFail: true}
      ],
    },

ref: gruntjs/grunt-contrib-concat#70

@jamesplease
Copy link
Member

👍

Another option would be accepting a string for nonull: "warn" or "fail". Setting it to true would be the same as warn for BC.

@vladikoff
Copy link
Member Author

@jmeas Yes!

@chrisweb
Copy link

+1

@stefanotorresi
Copy link

👍 for @jmeas idea

@vladikoff vladikoff modified the milestones: 0.4.6, 0.5.0 Jun 18, 2014
@cowboy
Copy link
Member

cowboy commented Jun 19, 2014

So there are a few possible things I can do.

Warn when all patterns/files fail to match
This could be easy:

  • if src has > 0 items and dest has 0 items, fail.

Warn when any pattern/file fails to match
This is not currently possible:

One method:

  • implicitly enable nonull, so that non-matching src patterns/filenames are included in dest.
  • search dest array for the existence of any item in src, which will be able to tell that a pattern like *.js failed to match because it will be in dest but will give false-positives on "plain" filename patterns like foo.js because regardless of it matching or not matching, foo.js will appear in dest.

Alternate method:

  • disable nonull (default), so that non-matching src patterns/filenames are excluded from dest.
  • search dest array for the existence of any item in src, which will be able to tell that a "plain" filename pattern like foo.js failed to match because it won't be in dest but will not be able to tell that a pattern like *.js didn't match because it won't appear in dest, whether it matched or not.

The (not yet in master) version of node-globule that will be in the next major version of Grunt will support both use-cases, since it emits a miss event when a pattern/filename fails to match. See the "Event Emitter" example.

So, for now, I could probably add in support for warning when all patterns/files fail to match (ie. dest is an empty array) but I don't see how to add in support for warning when any pattern/file fails to match.

@vladikoff vladikoff modified the milestones: 0.4.7, 0.4.6 Jun 19, 2014
@kemar
Copy link

kemar commented Jun 20, 2014

👍

@vladikoff vladikoff modified the milestones: 0.5.0, 0.4.7 Jul 11, 2014
@myspivey
Copy link

myspivey commented Mar 3, 2015

+1. Failure on missing files is crucial for automated builds

@arjunasuresh3
Copy link

+1

@slickorange
Copy link

Any update on this? Seems like a simple requirement? As mentioned above, this is crucial for automated builds. Thanks!

@lawlesscreation
Copy link

+1 as @slickorange said, crucial for automated builds.

@slickorange
Copy link

@lawlesscreation As a workaround add grunt.log.warn = grunt.warn; to the top of your Gruntfile .
If you now use concat with nonull: true you will get failures instead of just the warnings.

@lawlesscreation
Copy link

@slickorange not sure if it's just my build but when using grunt.log.warn = grunt.warn; it "aborts due to warnings" but doesn't tell me what the warning is. I get:

Warning: Cannot read property 'message' of undefined Use --force to continue.

I do have a complicate build and Gruntfile (using load-grunt-configs and load-grunt-tasks) so it could just be me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants