Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Gulp 4 tasks programmatically from other files #2203

Closed
thiagomajesk opened this issue Jul 9, 2018 · 7 comments
Closed

Run Gulp 4 tasks programmatically from other files #2203

thiagomajesk opened this issue Jul 9, 2018 · 7 comments

Comments

@thiagomajesk
Copy link

thiagomajesk commented Jul 9, 2018

Hi, I'd like to know if this is currently supported (or there's a workaround to it)...
What I'm trying to achieve is basically calling gulp tasks defined in other files without using the cli.

For instance, define a generic gulp task in a file:

const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');

gulp.task('css:run', (paths) => {
    const dist = '../output';
    return gulp.src(paths, { sourcemaps: true })
        .pipe(cleanCSS())
        .pipe(gulp.dest(dist));
});

And call it from another function:

const gulp = require('gulp');
/* require dependencie(s) */

function runTasksOnDemand() {
    /* run required/ imported task */
}

runTasksOnDemand();

PS.: I've looked into some SO questions, but the (scarce) answers for Gulp v4 were not enough to put me in any directions (at least in the way I needed).

@thiagomajesk thiagomajesk changed the title Run Gulp 4 task programmatically from other files Run Gulp 4 tasks programmatically from other files Jul 9, 2018
@phated
Copy link
Member

phated commented Jul 9, 2018

You really don't want to do this. The power of having "tasks" and running them is all in the CLI. You'll likely be able to find a much better way to achieve your goals than trying to run gulp tasks programatically.

@phated phated closed this as completed Jul 9, 2018
@thiagomajesk
Copy link
Author

@phated Actually, I do want to achieve this because I'm trying to wrap around gulp and gulp extensions.
Because of that, I can't depend on the cli to call the tasks.

Are there any real limitations that makes this impossible to achieve?

@phated
Copy link
Member

phated commented Jul 9, 2018

There's no reason to wrap around gulp. You likely want custom registries (documentation coming in the future).

@thiagomajesk
Copy link
Author

There's no reason to wrap around gulp

@phated How do you know I don't have a good reason for that!? :)

You likely want custom registries (documentation coming in the future).

Is there any tests/ issues where I can learn a little bit more about this API?

@phated
Copy link
Member

phated commented Jul 9, 2018

How do you know I don't have a good reason for that!? :)

Because this has been my life for 3 years and I've explored everything. The things people want are either handled by custom registries or a custom CLI.

Is there any tests/ issues where I can learn a little bit more about this API?

Have you used the search feature of github? It's been discussed before.
However, you can find the information we have at https://github.com/gulpjs/undertaker#custom-registries

@thiagomajesk
Copy link
Author

thiagomajesk commented Jul 9, 2018

Because this has been my life for 3 years and I've explored everything. The things people want are either handled by custom registries or a custom CLI.

Still, I'm trying to achieve something different - Maybe you haven't explored everything then ;)
Seriously though, thanks for trying to help.

Have you used the search feature of github? It's been discussed before.
However, you can find the information we have at https://github.com/gulpjs/undertaker#custom-registries

Yes, I have, but Github's search sometimes mixes a lot of undesired information about the repository.
Besides that, I don't find Github Issues a very reliable source of information about the current state of any project. Most of the times one will have to read through all of the history to just find simple information. Anyways, I'll read a little more about custom registries in the link you provided, thanks.

@phated
Copy link
Member

phated commented Jul 9, 2018

@thiagomajesk sounds good. I'm going to lock this because we don't provide support on this forum. If you have further support needs, you can email us for paid support.

@gulpjs gulpjs locked and limited conversation to collaborators Jul 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants