chyingp / grunt-inline

Brings externally referenced resources, such as js, css and images, into a single file.
MIT License
87 stars 55 forks source link

Regression in 0.3.3 #47

Closed knalli closed 9 years ago

knalli commented 9 years ago

Hi,

an issue is being introduced with the latest 0.3.3.

Given a configuration where a file named temp/error.html will be processed (with --stack):

Config:

  inline: {
    dev: {
      files: {
        src: ['temp/error.html']
      }
    }
  }

Log:

Reading temp/error.html...OK
Processing temp/error.html...Reading /fullpath/temp/styles/site_error.min.css...OK
Writing src...ERROR
Warning: Unable to write "src" file (Error code: EISDIR). Use --force to continue.
Error: EISDIR, illegal operation on a directory 'src'
    at Object.fs.openSync (fs.js:427:18)
    at Object.fs.writeFileSync (fs.js:966:15)
    at Object.file.write (/fullpath/node_modules/grunt/lib/grunt/file.js:296:10)
    at /fullpath/node_modules/grunt-inline/tasks/inline.js:39:15
    at Array.forEach (native)
    at Object.<anonymous> (/fullpath/node_modules/grunt-inline/tasks/inline.js:25:14)
    at Object.<anonymous> (/fullpath/node_modules/grunt/lib/grunt/task.js:264:15)
    at Object.thisTask.fn (/fullpath/node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.task.fn (/fullpath/node_modules/jit-grunt/lib/jit-grunt.js:99:30)
    at Object.<anonymous> (/fullpath/node_modules/grunt/lib/util/task.js:301:30)

The previous 0.3.2 works fine.

If it is required, I can provide more details later tomorrow.

chyingp commented 9 years ago

@knalli try version 0.3.4 and see whether your problem still exisist. Last night I published version 0.3.3 and later find some problem, and have already published version 0.3.4 to fixed it.

knalli commented 9 years ago

Nope, sorry, problem not solved in 0.3.4

chyingp commented 9 years ago

@knalli Try the bellow configuration and see if this can solve your problem?

  inline: {
    dev: {
        src: ['temp/error.html']
    }
  }

I looked into the source code of Grunt, and found that when we use files array formate (here) and don't set the dest property, Grunt will set the dest property to src by default. It puzzled me, I will look deeper into it later.

you can see the code here

    } else if (grunt.util.kindOf(data.files) === 'object') {
      for (prop in data.files) {
        files.push({src: data.files[prop], dest: grunt.config.process(prop)});
      }
    } else if (Array.isArray(data.files)) {
knalli commented 9 years ago

Yes, that helps and it works again. I'm quite sure I'd tried this syntax but it does not work (some months ago).

Anyway: For me this solution is okay. If you do not see any outstanding bug, we can close this.

@chyingp, thank you very much for the hint!

chyingp commented 9 years ago

@knalli glad to help :)