Get a list of gulp tasks from another module
See original GitHub issueHi @contra
Is there a way to retrieve the list of gulp tasks from an external module ?
for eg:
//foo.js
var gulp = require('gulp');
module.exports = function(){
var gulpTasks = Object.keys(gulp.tasks);
console.log(gulpTasks);
// some other stuff
}
//bar.js
require('foo')();
$ > node bar.js
//expect a list of gulp tasks, but getting an empty list
I am getting it to work when I add foo.js as a plugin inside my gulpfile and create a new task.
//gulpfile.js
var foo = require('foo');
gulp.task('fooTask',foo);
$> gulp fooTask
//outputs a list of tasks in gulpfile
The only thing I need gulp for inside foo.js is to get a list of gulp tasks all other stuff inside foo.js is no way related to gulp. Just not sure if foo.js needs to be a gulp plugin only for this purpose.
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to import all tasks from another gulp file.js - Stack Overflow
It is possible to have one main gulpfile.js from which to call tasks from other gulp files.js using the require-dir module.
Read more >Exporting tasks from gulpfile.js - Vjeko.com
This is a very simple way of exporting tasks. You call gulp.task, pass a reference to a function, and there you go. When...
Read more >Building multi module projects with Gulp - Sparkbit
Build definition of each module is now short and clean, you can see what tasks are run be just listing gulp-tasks directory.
Read more >Creating Tasks | gulp.js
Each gulp task is an asynchronous JavaScript function - a function that accepts an error-first callback or returns a stream, promise, event emitter, ......
Read more >How to Consume and Run Gulp Tasks in Other Files from a ...
The Gulp Part · Create a convenient and descriptive list of the sub folders this "hub" will be targeting. · A config object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@contra Nevermind, I figured it out:
had to use
tasks = Object.keys(require('./gulpfile')().tasks)
instead of thistasks = Object.keys(require('./gulpfile'))
Thanks again for your tip 👍
@contra with your help on this issue, I was able to finish a little pet project of mine : https://github.com/niki4810/gulp-devtools , wanted to share it with you. Thanks again for you help 😃