Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble using ‘this.files’ in GruntJS Tasks
    text
    copied!<p>Background: So I’m new to writing grunt tasks, so hopefully this isn’t a stupid question.<br> Purpose of my grunt task: Given a file (html / jsp / php / etc) search all the link / script tags, compare the href / src to a key, and replace with the contents of the file. Proposed task configuration:</p> <pre><code>myTask:{ index:{ files:{src:"test/testcode/index.html", dest:"test/testcode/index.html"}, css:[ { file: "/css/some/css/file.css", fileToReplace:"/target/css/file.css" }, { file: "/css/some/css/file2.css", fileToReplace:"/target/css/file2.css" } ], js:[ { file: "/css/some/css/file.css", fileToReplace:”/target/css/file.css" }, { file: "/css/some/css/file2.css", fileToReplace:"/target/css/file2.css" } ] } } </code></pre> <p>Problem: Now, per my understanding, when dealing with files, you should reference the ‘this.files’ object because it handles a bunch of nice things for you, correct? Using intelliJ and the debugger, I see the following when i watch the ‘this.files’ object: <a href="http://i.imgur.com/Gj6iANo.png" rel="nofollow">http://i.imgur.com/Gj6iANo.png</a> What I would expect to see is src and dest to be the same, not dest ===‘src’ and src === undefined.</p> <p>So, What is it that I am missing? Is there some documentation on ‘this.files’ I can read about? I’ve tried setting the files attribute in the target to a number of other formats per grunts spec, none seem to work (for this script, ideally the src / dest would be the same, so the user would just have to enter it once, but i’m not even getting in to that right now.)</p> <p>Thanks for the help</p> <p>EDIT: The underlying issue here is that I was using IntelliJ for debugging. For some reason, when i did a watch on this.files the src var (along with this.fileSrc var ) never was updated. even when I would see other items getting updated when appropriate.</p>
 

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