Git Product home page Git Product logo

gulp-require-tasks's People

Contributors

7studio avatar slavafomin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-require-tasks's Issues

Register tasks with the name of directories

Hi Slava,

First of all, thank you very much for your useful gulp plugin :D

I would like to suggest a new feature.
Here is my case:

I have these sub-directories to structure my tasks:

gulp/
  install/
    task1.js
    task2.js
  process/
  	task1.js
    task2.js
    task3.js
  build/

and this gulpfile.js:

var gulp = require('gulp');
var tasksLoader = require('gulp-require-tasks');
var runSequence = require('run-sequence');

tasksLoader({
    path: process.cwd() + '/gulp/tasks',
    gulp: gulp
});

gulp.task('install', ['install:task1', 'install:task2']);

gulp.task('process', function(done) {
    runSequence(
        ['process:task1'],
        ['process:task2'],
        ['process:task3'],
        done
    );
});

It could be very very useful if we could find a way to register tasks with the same
name than directories without creating them in the gulpfile.js or having files
with these names into the gulp/ directory.

I thought that having an index.js in the directories could register a gulp task with the name
of these directories.

Example:

gulp/
  install/
  	index.js
    task1.js
    task2.js
  process/
  	index.js
  build/

will register these tasks:

  • install
  • install:task1
  • install:task2
  • process

What do you think about this idea?

I would be happy to help you through a PR if you want to.
Xavier.

Share configuration variables across all task files

how does one pass in configurations stored in some variable?

Vars do not seem to be shared across multiple gulpjs files, but I store them in one place to avoid repeating things and also to keep the piping clean.

Load tasks from multiple directories

Is it somehow possible to use multiple path directories for example with glob patterns?
Lets say I have multiple modules with their own tasks directory.

taskLoader({
    gulp: gulp,
    path: __dirname + '/modules/**/tasks',
    passCallback: false
});

The path option documentation is not clear

The available information for the path option is not clear enough. The default value is process.cwd() + '/gulp-tasks' and not ./gulp-tasks.

When trying to import tasks from a relative directory, gulp will throw an error because it looks for a directory that is relative to the module directory and not the project root where gulpfile.js is located.

To reproduce the issue, try to import tasks from a relative path, like:

require('gulp-require-tasks')({
  path: './my-gulp-tasks'
});

Possible to retrieve values from dependencies?

Using the following syntax:

const compass = require('compass');
 
module.exports = {
  dep: ['styles:clean', 'icons:build'],
  fn: function (gulp, callback) {
    return gulp.src('...')
      .pipe(compass())
      .pipe(gulp.dest('...'))
    ;
  }
};

is there a way to declare a variable or an object in the dependencies and have it come through to the function being declared afterwards?

Here's my code for example. I am trying to compile templates from assemble.io.

gulpfile.js

const gulp = require('gulp');
require('gulp-require-tasks')();

gulp.task('build', [
	'assemble'
]);

gulp.task('default', ['build']);

assemble-load.js

'use strict';

module.exports = (gulp, callback) => {
	const path = require('path');
	const assemble = require('assemble')();

	assemble.helper(require(path.join(__dirname, '/../app/assemble/helpers/helpers.js')));

	assemble.partials([
		path.join(__dirname, '/../app/assemble/includes/*.hbs'),
		path.join(__dirname, '/../app/assemble/modules/*.hbs'),
		path.join(__dirname, '/../app/assemble/partials/*.hbs')
	]);
	assemble.layouts(path.join(__dirname, '/../app/assemble/layouts/*.hbs'));
	assemble.data(path.join(__dirname, '/../app/assemble/fixtures/*.json'));
  	assemble.pages(path.join(__dirname, '/../app/assemble/*.hbs'));

	return assemble;

	callback();
}

assemble.js

'use strict';

module.exports = {
	dep: ['assemble-load'],
	fn: function (gulp, callback) {
		
		const path = require('path');		
		const assemble = require('assemble')();
		const extname = require('gulp-extname');

		return assemble.toStream('pages')
			.pipe(assemble.renderFile())
			.pipe(extname())
			.pipe(assemble.dest('../app'));

	}
}

I had this working earlier in a more combined syntax, I'm just trying to get it into this fancy syntax, so I know my paths and such are correct. Also, outputting assemble to the console in assemble-load.js I can see all my templates and partials in the object. If I output assemble in assemble.js, it's just an empty object.

I'm not super solid on ES6 so I would appreciate code examples over vocabulary words. Thanks!

Sub-task triggers parent task

tasks/
    build/
        index.js
        watch/
            index.js

Tasks: build, build:watch

When running build:watch I'm not expecting build to run.
But they both run in parallel.

Also if I remove build/index.js there's an error: Task 'build' is not in your gulpfile

I think sub-tasks should be independent from parent tasks,
and users should explicitly run both if they want, instead of implicit run in parallel.
Eg. user may want to run parent-child in sequence, or do not run parent at all (my case).

In my case both build and build:watch tasks share same build/ folder,
but build:watch is not extension of the build, but rather - separate version of it.

What do you think? Is that conscious behavior or just a bug?

Unexpected token ...

Hi,

I've got this error :
/node_modules/gulp-require-tasks/index.js:93
taskNameParts.push(...pathInfo.dir.split(path.sep));
^^^

SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)

Do you know what can be the error ?

Thank you

__dirname + '/tasks' is not default value of path parameter

First of all thank you for this useful module.

I've noticed that when calling

gulpRequireTasks({});

default path parameter resolves to node_modules/gulp-require-tasks/tasks folder. This is not too big of an issue since we can initialize it with

gulpRequireTasks({
  // Pass any options to it. Please see below.
  path: __dirname + '/tasks' // This is default
});

But still I think it would make more sense to default it __dirname + '/tasks' . Also "// this is default" comment is misleading.

Thanks!

Add dependencies to package.json

Installing gulp-require-tasks will not install the required dependencies needed by gulp-require-taks (e.g. require-directory).

Please consider adding them to package.json so an user will not need to install the missing dependencies manually.

Question: Alternative syntax for dependencies

Hi there,

Thanks a lot for your gulp module, it works really cool and makes everything a lot more readable.
One question though: if a task has no dependencies the format is really compact like your sample:

module.exports = function (gulp, callback) {
  return gulp.src('...')
    .pipe(compass())
    .pipe(gulp.dest('...'))
  ;
};

But if there is a dependency one has to switch to the module as object syntax. Would it be possible to support a syntax similar to:

module.dependencies = ['task1, 'task2']
module.exports = function (gulp, callback) {
  return gulp.src('...')
    .pipe(compass())
    .pipe(gulp.dest('...'))
  ;
};

This looks somehow a little bit cleaner than the module as object way. Though really don't know if this is possible. Thanks for your thoughts on this.

arguments is an empty object in on.('finish') callback

Seems that the arguments is empty in the on finish callback, or am I doing something wrong here?

var chug = require('gulp-chug');

module.exports = function (gulp, arguments, callback) {
    return gulp.src( arguments.path + 'gulpfile.js' )
        .pipe( chug( {
                    tasks: [ 'build' ],
                    args:   [ '--ip=' + arguments.ip, '--api=' + arguments.api , '--https=' + arguments.https]}) )
        .on('finish', function() {
            console.log(arguments) //arguments is {} here (empty)
            gulp.src([arguments.path + '/dist/**/*'])
            .pipe(gulp.dest('a-destination-name'));
        });
};

Multiple tasks in a single file?

Can you still have multiple tasks in the same file? Sometimes you want to have multiple tasks in one file because they might all use some shared variables declared at the top of the file, and the tasks might be logically-related so it makes sense to have them in the same file.

Synchronous tasks without callback don't finish

In line 55 function taskFunction (callback) { ... } defines a parameter (callback) that conflicts with orchestrator's runTask which relies in Function.length and interprets that the task terminates only after the callback is called.

In this sense, the config argument passCallback lacks purpose and the tasks written in separate files are obliged to function with a callback parameter or they won't finish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.