grunt-critical
grunt-critical copied to clipboard
Fatal error: Unable to write "dist/" file (Error code: EISDIR).
Hi
I am running the following configuration in my Gruntfile:
critical: {
dist: {
options: {
base: './',
width: 1300,
height: 900
},
src: '**/*.html',
dest: 'dist/'
}
}
})
The idea is that I pick up all HTML files and then dump them into my "dist" folder. When I run this, I unfortunately get the following error:
"Fatal error: Unable to write "dist/" file (Error code: EISDIR)."
If I run the task with --stack, I get the following output
Error: EISDIR, illegal operation on a directory 'C:\Users\dean.hume\Documents\GitHub\typography\dist'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.writeFileSync (fs.js:966:15)
at Object.file.write (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt\lib\grunt\file.js:296:10)
at C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\tasks\critical.js:63:36
at C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\index.js:275:13
at tryCatcher (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\util.js:24:31)
at Promise._settlePromiseFromHandler (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:454:31)
at Promise._settlePromiseAt (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:530:18)
at Promise._settlePromises (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:646:14)
at Async._drainQueue (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\async.js:177:16)
I've also tried running this without the subdirectory src, eg:
src: '*.html',
dest: 'dist/'
But unfortunately I still get the same error. I'm not sure if the task is looking for a file instead of a directory.....
try
files: [
{cwd: '.', src: ['*.html'], dest: 'dist'}
]
Hmmm...that didn't seem to work for me. I've created a pull request and fixed the issue. Let me know what you think!
@deanhume pr landed.
src: '*.html',
dest: 'dist/'
should work as expected. Wanna give it a try?
Hmmmm...almost there - except I get a different error this time.
Fatal error: Maximum call stack size exceeded
I am running it against 12 files. Not sure, but my original pull request seemed to work. Any ideas?
Thanks for you help!
If you need any more detail around this error, please let me know!
@deanhume more detail please ;) I'm not able to reproduce the call stack error on my side.
@deanhume any updates on this?
Hey @bezoerb I'm also experiencing the same issue:
Running "critical:dist" (critical) task
Unhandled rejection RangeError: Maximum call stack size exceeded
at new Error (native)
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
And the critical
Grunt task:
critical: {
dist: {
options: {
base: './',
css: [
'dist/assets/css/style.css'
],
ignore: ['@font-face'],
width: 320,
height: 480
},
src: ['dist/**/*.html'],
dest: 'test/'
}
},
It works fine if I change src
to e.g. src: dist/index.html
and dest
to dest: dist/index.html
i.e. replaces the existing file with the inline <style>
element.
Versions:
npm 2.14.7
node 4.2.2
Windows 8.1
Any ideas? Thanks in advance!
@bezoerb @deanhume the problem seems to be that src
and dest
only accept strings (file names).
If I change the Grunt task to:
src: 'dist/index.html',
dest: 'test/index.html'
It works as expected. If I change it to:
src: 'dist/index.html',
dest: 'test'
It creates a file test
(without an extension) and works as expected (CSS is inlined).
If I change it to e.g.
src: 'dist/index.html',
dest: 'test/'
i.e. a directory test/
it throws this error:
Unhandled rejection RangeError: Maximum call stack size exceeded
at new Error (native)
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
at mkdirsSync (C:\path_to_project\node_modules\grunt-critical\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:22:9)
@michaelthorne thanks for the debugging :) I hope to have some time within the next days to provide a fix
@bezoerb no worries! Let me know if there's any testing I can help with. Thanks.