0

This is my task

export default function glsl() {
  return src(conf["glsl"])
    .pipe(plumber({ errorHandler: false}))
    .pipe(bytediff.start())
    // Minify the file
    .pipe(glslmin())
    // Output    
    .pipe(plumber.stop())
    .pipe(bytediff.stop(byteDiffCB))
    .pipe(dest("./dist"))
}

this is what happens when i run gulp glsl

[16:55:15] Requiring external module ts-node/register
[16:55:17] Using gulpfile ~/Documents/gulp-gameoptimizer/gulpfile.ts
[16:55:17] Starting 'glsl'...
[16:55:17] 'glsl' errored after 97 ms
[16:55:17] Error in plugin "gulp-glsl"
Message:
    glsl/2xbr-hybrid-v5-gamma.glsl: SyntaxError: Expected "(", identifier, or whitespace but "v" found.
Details:
    domainEmitter: [object Object]
    domainThrown: false

What I would ideally want to happen (though i can't figure out how to do it), is when a plugin gives an error, copy the source file to the destination, then resume the task. In other words act as if the plugin weren't there.

  • Do you know under which conditions this error occurs or when you would want to ignore this plugin vs. not ignore this plugin? – Randy Casburn Jan 24 '21 at 15:02
  • Regardless, you can use this solution. you might have to test the contents of the previous return manually, but this is how it is done. Does this answer your question? [Gulp condition inside pipe](https://stackoverflow.com/questions/27181719/gulp-condition-inside-pipe) – Randy Casburn Jan 24 '21 at 15:05
  • I think it'll work. The error usually occurs because whoever wrote the code did a bad job, or because the plugin hasn't been updated to handle some new feature in the language. As for when i want to ignore, that would be always. My gulpfile is meant to reduce the size of video games. So if a file doesn't want to be minified, i'm fine with using the original. – Mony Armenchev Jan 24 '21 at 15:09
  • Ah...could not figure out how a build process would be sane by randomly ignoring a build step - but that makes perfect sense. – Randy Casburn Jan 24 '21 at 15:12
  • Using gulp-if doesn't seem to work, cause as soon as there's an error the task ends, and i have no way of detecting that there was an error, and resuming, I can't use onerror, cause it just ends the task, and i can't resume it afterwards. – Mony Armenchev Jan 24 '21 at 15:38
  • "_As for when i want to ignore, that would be always_" - remove the call to the plugin - you always want to ignore it. Or is there _some other_ situation that you don't really want to ignore it? Still can't figure out why you don't just remove that call. – Randy Casburn Jan 24 '21 at 15:45
  • Basically it's like this, for some files the plugin works just fine, it minifies them without issue, for other files it gives an error and stops. What i want, is if it minifies without issue, do nothing, if it errors and stops, then copy the original file over, and resume the task. – Mony Armenchev Jan 24 '21 at 15:48
  • replicate the same test the plug in uses to determine if the input contents will work. Do this in your conditional (function call is ok). If your manual test fails (the same way the plug-in fails), task is to copy original -otherwise task is to run plug-in. – Randy Casburn Jan 24 '21 at 15:51

0 Answers0