{"id":16057733,"url":"https://github.com/tfrommen/grunt-delegate","last_synced_at":"2025-07-20T07:33:10.203Z","repository":{"id":42576364,"uuid":"55859404","full_name":"tfrommen/grunt-delegate","owner":"tfrommen","description":"Run a task (and an optional target) while using an arbitrary set of files to run checks against.","archived":false,"fork":false,"pushed_at":"2016-04-10T09:39:31.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-12T20:15:21.584Z","etag":null,"topics":["grunt-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/grunt-delegate","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfrommen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-09T18:03:37.000Z","updated_at":"2023-02-23T19:48:29.000Z","dependencies_parsed_at":"2022-07-08T05:26:32.727Z","dependency_job_id":null,"html_url":"https://github.com/tfrommen/grunt-delegate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tfrommen/grunt-delegate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Fgrunt-delegate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Fgrunt-delegate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Fgrunt-delegate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Fgrunt-delegate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfrommen","download_url":"https://codeload.github.com/tfrommen/grunt-delegate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfrommen%2Fgrunt-delegate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266085590,"owners_count":23874470,"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":["grunt-plugin"],"created_at":"2024-10-09T03:04:27.546Z","updated_at":"2025-07-20T07:33:10.131Z","avatar_url":"https://github.com/tfrommen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-delegate [![Build Status](https://travis-ci.org/tfrommen/grunt-delegate.svg?branch=master)](http://travis-ci.org/tfrommen/grunt-delegate)\n\n\u003e Run a task (and an optional target) while using an arbitrary set of files to run checks against.\n\n## Getting Started\n\nIf you haven't used [Grunt](http://gruntjs.com) before, be sure to check out the [Getting started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins.\nOnce you're familiar with that process, you may install this plugin with this command:\n\n```shell\n$ npm i -D grunt-delegate\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks( 'grunt-delegate' );\n```\n\n## Configuration\n\nThere are no options for the `delegate` [multi task](http://gruntjs.com/creating-tasks#multi-tasks) itself.\n\nEach target configuration can have an optional `task` property that holds the name of another task.\nIf a task is specified, Grunt tries to run it (see ES6 example below).\nOtherwise, Grunt tries to run a task with the name of the current target (see SASS example below).\n\n## Usage\n\n_Run this task with the `$ grunt delegate` command._\n\nTask targets and files may be specified according to the Grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.\n\nThe primary goal of this task is to specify a set of files (e.g., by defining a `src` property) that you can use in the context of another task.\nThis can be achieved by not running the `delegate` task directly, but indirectly via another task.  \nNot yet perfectly clear? Let's see some real world examples then...\n\n### Examples\n\n#### Convert `.scss` files if any of them changed since the last run\n\nIn this example, running `$ grunt changed:delegate:sass` will run the `sass` task if any `.scss` file changed since the last run.  \nYou cannot just run `$ grunt changed:sass`, because the files specified in the `sass` task are the _root_ files only.\nThus, `grunt-changed` is unaware of changed partials or modules.  \nBy having `grunt-changed` check the files provided by the `delegate` configuration, however, **any** changed `.scss` file (compare `resources/scss/**/*.scss` with `resources/scss/*.scss`) will cause the `sass` task to get run.\n\n```js\ngrunt.initConfig( {\n\tdelegate: {\n\t\tsass: {\n\t\t\tsrc: [ 'resources/scss/**/*.scss' ]\n\t\t}\n\t},\n\n\tsass: {\n\t\tall: {\n\t\t\texpand: true,\n\t\t\tcwd: 'resources/scss/',\n\t\t\tsrc: [ '*.scss' ],\n\t\t\tdest: 'assets/css/',\n\t\t\text: '.css'\n\t\t}\n\t}\n} );\n```\n\n#### Transpile ES6 `.js` files if any of them is newer than the time of the last run\n\nIn this example, running `$ grunt newer:delegate:transpile` will run the `browserify` task with the `admin` target (see the `task` property of the according `delegate` configuration) if any `.js` file is newer than the time of the last run.  \nYou cannot just run `$ grunt newer:browserify:admin`, because the file specified in the `browserify` task is the _main_ file only.\nThus, `grunt-newer` is unaware of newer modules or helper files.  \nBy having `grunt-newer` check the files provided by the `delegate` configuration, however, **any** newer `.js` file (compare `resources/js/**/*.js` with `resources/js/admin.js`) will cause the `browserify` task with the `admin` target to get run.\n\n```js\ngrunt.initConfig( {\n\tdelegate: {\n\t\ttranspile: {\n\t\t\tsrc: [ 'resources/js/**/*.js' ],\n\t\t\ttask: 'browserify:admin'\n\t\t}\n\t},\n\n\tbrowserify: {\n\t\tadmin: {\n\t\t\toptions: {\n\t\t\t\ttransform: [\n\t\t\t\t\t[ 'babelify' ]\n\t\t\t\t]\n\t\t\t},\n\t\t\tsrc: [ 'resources/js/admin.js' ],\n\t\t\tdest: 'assets/js/admin.js'\n\t\t},\n\n\t\tvendor: {\n\t\t\toptions: {\n\t\t\t\trequire: [ 'jquery' ]\n\t\t\t},\n\t\t\tsrc: [],\n\t\t\tdest: 'public/vendor.js'\n\t\t},\n\t}\n} );\n```\n\n#### Test `.php` source files if any of them or one of the tests is newer than the time of the last run\n\nIn this example, running `$ grunt newer:delegate:phpunit` will run the `shell` task with the `phpunit` target (see the `task` property of the according `delegate` configuration) if any `.php` source files or tests is newer than the time of the last run.  \nYou cannot just run `$ grunt newer:shell:phpunit`, because in the `shell` task are no files specified.  \nBy having `grunt-newer` check the files provided by the `delegate` configuration, however, **any** newer `.php` source file or test will cause the `shell` task with the `phpunit` target to get run.\n\n```js\ngrunt.initConfig( {\n\tdelegate: {\n\t\tphpunit: {\n\t\t\tsrc: [ 'src/**/*.php', 'tests/**/*.php' ],\n\t\t\ttask: 'shell:phpunit'\n\t\t}\n\t},\n\n\tshell: {\n\t\tphpunit: {\n\t\t\tcommand: 'phpunit'\n\t\t}\n\t},\n} );\n```\n\n#### Run an alias task when specific files changed since the last run\n\nIn this example, running `$ grunt changed:delegate:scripts` will run the `scripts` [alias task](http://gruntjs.com/creating-tasks#alias-tasks) if any `.js` source files changed since the last run.  \nYou cannot just run `$ grunt changed:scripts`, because in the `scripts` task are no files specified.  \nBy having `grunt-changed` check the files provided by the `delegate` configuration, however, **any** changed `.js` source file will cause the `scripts` alias task to get run.\n\n```js\ngrunt.initConfig( {\n\tdelegate: {\n\t\tscripts: {\n\t\t\tsrc: [ 'resources/js/**/*.js' ],\n\t\t\ttask: 'scripts'\n\t\t}\n\t},\n\n\t// Other task configurations here...\n} );\n\ngrunt.registerTask( 'scripts', [\n\t'eslint:src',\n\t'shell:tape',\n\t'browserify',\n\t'jsvalidate:dest',\n\t'lineending:scripts',\n\t'uglify'\n] );\n```\n\n## License\n\nThis plugin is licensed under the [MIT license](LICENSE).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n---\n\nTask submitted by [Thorsten Frommen](https://github.com/tfrommen).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfrommen%2Fgrunt-delegate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfrommen%2Fgrunt-delegate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfrommen%2Fgrunt-delegate/lists"}