Gulp watch option

Gulp watch option

If there is some kind of error during styles compilation, gulp-stylus plugin throws an it's ok, because I want build process to exit with non-zero code when building for production.
But for development I use to recompile styles "on the fly":

Javascript - Is it possible to pass a flag to Gulp to have

throw er // Unhandled 'error' event
[gulp] Error in plugin 'gulp-tsc': Failed to compile: tsc command has exited with code:6

Src() ·

if(env === 'testing'){ var Config = require('./') var Api = require('./api/')() } else if(env === 'dev'){ Config = require('./') Api = require('./api/').Api } else{ Config = require('./') Api = require('./api/')() }

GitHub - gulp-community/gulp-concat: Streaming concat

Just a quick update: I was waiting until the new task system in gulp for this to be fixed but it seems to be a large enough issue that I put a hotfix in place in . Watch will no longer stop and the process will no longer exit just because an error was thrown.

-The streaming build system

I am using GULP CLI (installed globally) and GULP (installed locally) here is how you do it without any additional plugin. I think the code is quite self-explanatory.

The watch() API connects globs to tasks using a file system watcher. It watches for changes to files that match the globs and executes the task when a change occurs. If the task doesn't signal Async Completion , it will never be run a second time.

Failing the task on an error seems like the most common use case. If you want to define what failed is yourself you can use the callback pattern to give you more control.

It eats an argument-name and will search for this in . If nothing was found it spits out null. Otherwise if their is no next argument or the next argument is a command and not a value (we differ with a dash) true gets returned. (That's because the key exist, but there's just no value). If all the cases before will fail, the next argument-value is what we get.

On the other hand, it's very annoying that I need to restart gulp watch whenever I have a syntax error in my source files. I could use until gulp watch do sleep 6 done , but it's not the best solution.

There is no error or warning message provided because the file watcher keeps your Node process running. Since the process doesn't exit, it cannot be determined whether the task is done or just taking a really, really long time to run.

The error handler I copied out of the Plumber source which puts the pretty colors, then I added the ('end') bit from Kirk's link which solves the watcher crashing issue.

Files will be concatenated in the order that they are specified in the function. For example, to concat ./lib/ , ./lib/ and ./lib/ in that order, the following code will create a task to do that:

I feel like there is some misunderstanding in this thread. One reason that we need the non-zero exit code is for when you're running a gulp command in a CI environment, as a check to make sure that everything can be compiled without errors. In that case you want your build to fail, but if you swallow the errors with any of the solutions above, your CI service will assume that everything has passed. So we only want to ignore errors during watch , and crash normally otherwise.

//passing in flag to gulp to set environment //var env = if (typeof === 'string') { _ENV = }

When a string or array is passed as task , throws an error with the message, watch task has to be a function (optionally generated by using or ).

To change the newLine simply pass an object as the second argument to concat with newLine being whatever ( \r\n if you want to support any OS to look at it)

When the globs argument can only match one file (such as foo/ ) and no match is found, throws an error with the message, File not found with singular glob. To suppress this error, set the allowEmpty option to true.

The watch() method returns the underlying instance of chokidar , providing fine-grained control over your watch setup. Most commonly used to register individual event handlers that provide the path or stats of the changed files.

The problem here is that orchestrator listens for the error event on the returned stream when you use that format. When it sees an error, it marks the task as errored and kills the chain. Just use the callback format instead if you don't want that behavior.

Leave a comment