vanjacosic / gulp-asset-manifest

gulp plugin for adding generated assets to a manifest file
MIT License
7 stars 4 forks source link

Bug: Crashes when manifest file does exist but has no contents #4

Closed dan-turner closed 10 years ago

dan-turner commented 10 years ago

Attempting to generate a manifest where a manifest file does already exists but is empty, results in the following:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at resetManifestFile (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp-asset-manifest\index.js:43:25)
    at module.exports (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp-asset-manifest\index.js:79:5)
    at Gulp.gulp.task.gulp.src.pipe.lintspaces.ignores (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\gulpfile.js:73:15)
    at module.exports (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp\node_modules\orchestrator\lib\runTass:34:7)
    at Gulp.Orchestrator._runTask (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp\node_modules\orchestratondex.js:273:3)
    at Gulp.Orchestrator._runStep (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp\node_modules\orchestratondex.js:214:10)
    at Gulp.Orchestrator.start (D:\Code\DP\HLC\src\app\HomeLoanCalc.Web\node_modules\gulp\node_modules\orchestrator\ix.js:134:8)
    at C:\Users\turnerd\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:121:20
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3

This is the expected behavior of JSON.parse against an empty string, therefore the plugin should check that file contents exist before trying to parse.

vanjacosic commented 10 years ago

@dan-turner Good catch! Thanks for contributing a fix :)