Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've had similar problem: I wanted my build to fail if there are files with the same file names detected in given path pattern. I have solved it by writing custom task. You could use grunt.file.expand or grunt.file.recurse <a href="http://gruntjs.com/api/grunt.file#grunt.file.recurse" rel="nofollow">GruntAPI</a></p> <p>Maybe this will help you (this is coffeescript rather than js).</p> <pre class="lang-coffeescript prettyprint-override"><code> grunt.registerMultiTask "noduplicates", "Detects duplicated filenames", () -&gt; path = require('path') dupFilenamesCounted = {} haveDuplicates = false options = cwd: this.data.cwd grunt.file.expand(options, this.data.src).forEach (filepath) -&gt; filepathParts = filepath.split(path.sep) filename = filepathParts.slice(-1).join(path.sep) unless dupFilenamesCounted[filename] is undefined dupFilenamesCounted[filename].counter++ dupFilenamesCounted[filename].filepaths.push(filepath) else dupFilenamesCounted[filename] = { counter: 0, filepaths: [ filepath ] } for filename of dupFilenamesCounted if dupFilenamesCounted[filename].counter &gt; 0 grunt.log.error "Filename: " + filename + ' has ' + dupFilenamesCounted[filename].counter + ' duplicates: ' + dupFilenamesCounted[filename].filepaths haveDuplicates = true # Fail by returning false if this task had errors return false if haveDuplicates </code></pre> <p>Then you define your task:</p> <pre><code>noduplicates: images: cwd: '&lt;%= pkg.src %&gt;' src: [ 'static/**/*.{gif,png,jpg,jpeg}' ] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload