-->

Can an assemble target be silenced if there are no

2019-07-01 18:09发布

问题:

I have this assemble grunt target:

docs: {
  files: {'<%= site.tmp %>/': ['<%= site.pages %>/**/*.html'] }
},

If there is no matching content, it complains, saying "Warning: Source files not found. Use --force to continue". The task then aborts. I don't mind the warning but I would like the option to configure the task to continue rather than having to use "--force" on the command line. Is this possible?

ps. The reason why this task is now failing is that I have converted the content to markdown. I am trying to build a scaffold that allows users to use markdown, hbs or html in any combination.

回答1:

Based on what you are saying, you can use a little unix trick here.

docs: {
  files: {'<%= site.tmp %>/': ['<%= site.pages %>/**/*.{html,hbs,md}'] }
},

That code basically looks for anything ending in .html, .hbs, or .md.

Since this is really a Grunt error, you would need to simply write your file object to allow for more possibilities.

For example, the above would only work if the location actually has files. If Grunt looks in that location and doesn't see any of the acceptable files, it will display the error you are getting now.