Gulp isn't running tasks in a series #2473
-
I'm trying to write a function that will delete files in dist that no longer exist in src. When I run the task "clean" below with "gulp clean" on the command line, I only get "clean" as console output, and no files are created. This means that readSrcFiles, readDistFiles, and parseFiles aren't running for some reason. Why?
At first I didn't have this split up into functions, but then it would only run the src command that was being returned, which obviously didn't let me do anything afterwards. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
@EmilyBonar You shouldn't be putting I highly recommend you read through the "Getting started" guide on our website which explains tasks and async completion. It will also show you to use exports instead of the |
Beta Was this translation helpful? Give feedback.
-
I had read it, but after some more digging I ended up with this, which works.
This still leaves me with the smaller problem that readSrcFiles and readDistFiles copy their whole folders instead of just writing the json I want, but at least it'll work for now. |
Beta Was this translation helpful? Give feedback.
-
I'm still pretty new to JavaScript, so if there's a better way I'm all
ears. The main thing I started using Gulp for is to inject
headers/footers/etc into my static site. That meant I had src and dist
folders, so I needed to manage the differences between them. The live
server is nice too.
…On Sun, Aug 2, 2020, 8:06 PM Blaine Bublitz ***@***.***> wrote:
At this point, you are just using gulp as a globbing library against your
files. Why wouldn't you just use a globbing library since they don't read
any files? Remember that gulp is just javascript and you can use any
libraries that are suitable for the job! There's no need to shoehorn gulp's
filesystem access into weird use cases it wasn't made for.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2473 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADTBH7DDUHITN4BAVZGVL5LR6YES5ANCNFSM4PSZTA7A>
.
|
Beta Was this translation helpful? Give feedback.
@EmilyBonar You shouldn't be putting
task()
calls inside another task; there would be no way for gulp to know that a task would be registered inside.I highly recommend you read through the "Getting started" guide on our website which explains tasks and async completion. It will also show you to use exports instead of the
task
function which isn't recommended anymore because people end up in situations like you've described.