{"id":13447293,"url":"https://github.com/betsol/gulp-require-tasks","last_synced_at":"2025-07-09T22:30:44.416Z","repository":{"id":57258731,"uuid":"53281008","full_name":"betsol/gulp-require-tasks","owner":"betsol","description":"Splits Gulpfile into multiple individual files","archived":false,"fork":false,"pushed_at":"2020-04-28T04:15:09.000Z","size":31,"stargazers_count":49,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T06:45:36.172Z","etag":null,"topics":["gulp","gulp-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/betsol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-06T23:05:45.000Z","updated_at":"2022-04-04T05:47:03.000Z","dependencies_parsed_at":"2022-08-28T21:41:44.488Z","dependency_job_id":null,"html_url":"https://github.com/betsol/gulp-require-tasks","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/betsol/gulp-require-tasks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betsol%2Fgulp-require-tasks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betsol%2Fgulp-require-tasks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betsol%2Fgulp-require-tasks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betsol%2Fgulp-require-tasks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betsol","download_url":"https://codeload.github.com/betsol/gulp-require-tasks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betsol%2Fgulp-require-tasks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263541535,"owners_count":23477454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-plugin"],"created_at":"2024-07-31T05:01:13.139Z","updated_at":"2025-07-09T22:30:44.168Z","avatar_url":"https://github.com/betsol.png","language":"JavaScript","readme":"# gulp-require-tasks\n\n[![npm version](https://badge.fury.io/js/gulp-require-tasks.svg)](http://badge.fury.io/js/gulp-require-tasks)\n\n\nThis convenient extension for **Gulp 3** allows you to load tasks from\nmultiple individual files in a directory hierarchy.\n\n\n# Deprecation Notice\n\n\u003e This extension is deprecated and archived! Use [Gulp 4][gulp-4] with [Gulp Hub][gulp-hub] instead.\n\u003e\n\u003e PRs are not being accepted. Consider creating a fork if you really want it.\n\n\n## Features\n\n- Loads individual task files recursively from the specified directory\n- The name of the task is inferred from the directory structure, e.g. `styles:preprocess:clean`\n- Easily integrates into the `gulpfile.js` without breaking your existing tasks\n- Gulp instance and task callback are automatically passed to your task function\n- Very flexible: almost all aspects of the module is configurable\n- Each task is stored in it's own local node module to completely separate concerns\n\n\n## Installation\n\n### `npm i -D gulp gulp-require-tasks`\n\n\n## Usage\n\nCreate a directory alongside your `gulpfile.js` to store your individual\ntask modules, e.g. `./gulp-tasks`. Place your tasks into this directory.\nOne task per JavaScript file. Use sub-directories to structure your tasks.\n\nLoad tasks from your `gulpfile.js`:\n\n```js\n\n// gulpfile.js:\n\n// Require the module.\nconst gulpRequireTasks = require('gulp-require-tasks');\n\n// Invoke the module with options.\ngulpRequireTasks({\n\n  // Specify path to your tasks directory.\n  path: process.cwd() + '/gulp-tasks' // This is default!\n\n  // Additionally pass any options to it from the table below.\n  // ...\n\n});\n\n// Or, use minimal invocation possible with all options set to defaults.\ngulpRequireTasks();\n\n```\n\n\n### Minimal Gulp file possible\n\n```js\n// gulpfile.js:\nrequire('gulp-require-tasks')();\n```\n\nOr with options:\n\n```js\n// gulpfile.js:\nrequire('gulp-require-tasks')({\n  separator: '.'\n});\n```\n\n\n## Options\n\n| Property     | Default Value     | Description\n| ------------ | ----------------- | --------------------------------------------------------\n| path         | `'./gulp-tasks'`  | Path to directory from which to load your tasks modules\n| separator    | `:`               | Task name separator, your tasks would be named, e.g. `foo:bar:baz` for `./tasks/foo/bar/baz.js`\n| passGulp     | `true`            | Whether to pass Gulp instance as a first argument to your task function\n| passCallback | `true`            | Whether to pass task callback function as a last argument to your task function\n| gulp         | `require('gulp')` | You could pass your existing Gulp instance if you have one, or it will be required automatically\n\n\n## Task module format\n\nConsider you have the following task module: `gulp-tasks/styles/build.js`.\n\n\n### Module as a function\n\nYou could define module as a task function. Gulp instance and\ncallback function would be passed to it, if not configured otherwise.\n\nYou could configure the library to pass additional arguments as well.\n\n```javascript\n\n// gulp-tasks/styles/build.js:\n\nconst compass = require('compass');\n\nmodule.exports = function (gulp, callback) {\n  return gulp.src('...')\n    .pipe(compass())\n    .pipe(gulp.dest('...'))\n  ;\n};\n```\n\n\n### Module as an object\n\nAlso, you could define your task module as an object.\nThis will allow you to provide additional configuration.\n\n```javascript\n\n// gulp-tasks/styles/build.js:\n\nconst compass = require('compass');\n\nmodule.exports = {\n  deps: ['styles:clean', 'icons:build'],\n  fn: function (gulp, callback) {\n    return gulp.src('...')\n      .pipe(compass())\n      .pipe(gulp.dest('...'))\n    ;\n  }\n};\n```\n\nYou will have to define your task function as `fn` parameter.\nYou could use `deps` parameter to define your task dependencies.\n\nAlso, you could use `nativeTask` instead of `fn` property to make your\ntask function executed by Gulp directly. That way, additional arguments\nwill not be passed to it. This feature is useful when using,\ne.g. [gulp-sequence][gulp-sequence] plugin or for [synchronous tasks](#synchronous-tasks).\n\n\n### Task function return value\n\nTo make sure, that task is finished correctly you must either:\n\n- Return a proper Gulp stream from the task function, e.g.: `return gulp.src().pipe(gulp.dest());`\n- Return a valid Promise (thenable object), e.g.: `return del();` or `return new Promise();`\n- Call a callback function passed to it, e.g.: `callback();`\n\n\u003e WARNING: If your task function is synchronous — please read the section below!\n\n\n### Using root directory tasks\n\nStarting from version `1.1.0` you can place `index.js` inside of the task directories.\nThe actual task, registered with Gulp will have the name of the directory itself,\ne.g.: `scripts/build/index.js` will become: `scripts:build`.\n\nThe `index.js`, placed in the root of tasks directory, will be registered as a `default` task.\n\n\n### Passing data to the task function\n\nIf you need to pass something to the task function from your gulpfile you can use globals.\n\nDefine your custom properties on the `global` object:\n\n```js\n// gulpfile.js\n\nglobal.SOURCES_BASE_PATH = __dirname + '/src';\n```\n\nAnd then use it in your task module:\n\n```js\n// gulp/tasks/styles/build.js\nmodule.exports = gulp =\u003e\n  gulp.src(global.SOURCES_BASE_PATH + '/styles/*.scss')\n    .pipe(compass())\n    .pipe(gulp.dest('…'))\n;\n```\n\n\n### Synchronous tasks\n\nIf you are using synchronous tasks, i.e. tasks which execute synchronously\nwithout returning streams, promises or accepting callbacks, you will have\nto use one of the workarounds specified below:\n\n1). The simplest method is to use `nativeTask` functionality, here's the\nexample of the module with native task synchronous function:\n\n```js\nmodule.exports = {\n  nativeTask: function () {\n    console.log('This is the synchronous native task without a callback!');\n  }\n};\n```\n\n2). You should call a callback explicitly:\n\n```js\nmodule.exports = function (gulp, callback) {\n  console.log('This is the synchronous native task with explicit callback!');\n  callback(); // Don't forget this, otherwise task will never finish!\n};\n```\n\nHowever, if `config.passCallback == false` you won't be able to use the second method.\n\nThese workarounds must be used due to architectural limitation of this module integration with orchestrator.\nPlease see the issue\n[#9: Synchronous tasks without callback don't finish](https://github.com/betsol/gulp-require-tasks/issues/9)\nfor more technical details.\n\n\n## Changelog\n\nPlease see the [changelog][changelog] for list of changes.\n\n\n## Feedback\n\nIf you have found a bug or have another issue with the library —\nplease [create an issue][new-issue].\n\nIf you have a question regarding the library or it's integration with your project —\nconsider asking a question at [StackOverflow][so-ask] and sending me a\nlink via [E-Mail][email]. I will be glad to help.\n\nHave any ideas or propositions? Feel free to contact me by [E-Mail][email].\n\nCheers!\n\n\n## Support\n\nIf you like this library consider to add star on [GitHub repository][repo-gh].\n\nThank you!\n\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016-2020 Slava Fomin II\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n  [changelog]:     CHANGELOG.md\n  [so-ask]:        http://stackoverflow.com/questions/ask?tags=node.js,javascript\n  [email]:         mailto:s.fomin@betsol.ru\n  [new-issue]:     https://github.com/betsol/gulp-require-tasks/issues/new\n  [gulp]:          http://gulpjs.com/\n  [repo-gh]:       https://github.com/betsol/gulp-require-tasks\n  [gulp-sequence]: https://github.com/teambition/gulp-sequence\n  [gulp-4]:        https://gulpjs.com/\n  [gulp-hub]:      https://github.com/frankwallis/gulp-hub/tree/registry-init\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetsol%2Fgulp-require-tasks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetsol%2Fgulp-require-tasks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetsol%2Fgulp-require-tasks/lists"}