{"id":23714797,"url":"https://github.com/happycoda/grunt-subscribe","last_synced_at":"2025-10-30T03:41:29.804Z","repository":{"id":57285261,"uuid":"51518237","full_name":"happyCoda/grunt-subscribe","owner":"happyCoda","description":"Grunt plugin for easy event emitting","archived":false,"fork":false,"pushed_at":"2016-02-11T15:01:36.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T05:01:49.250Z","etag":null,"topics":["grunt","grunt-plugins","plugins"],"latest_commit_sha":null,"homepage":null,"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/happyCoda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-11T14:01:05.000Z","updated_at":"2017-05-04T22:23:53.000Z","dependencies_parsed_at":"2022-09-04T20:20:56.766Z","dependency_job_id":null,"html_url":"https://github.com/happyCoda/grunt-subscribe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyCoda%2Fgrunt-subscribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyCoda%2Fgrunt-subscribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyCoda%2Fgrunt-subscribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyCoda%2Fgrunt-subscribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happyCoda","download_url":"https://codeload.github.com/happyCoda/grunt-subscribe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239801239,"owners_count":19699308,"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","grunt-plugins","plugins"],"created_at":"2024-12-30T20:37:59.059Z","updated_at":"2025-10-30T03:41:29.708Z","avatar_url":"https://github.com/happyCoda.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-subscribe\n\n\u003e Emits events when previous tasks have been completed\n\n## Getting Started\nThis plugin requires Grunt `~0.4.5`\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. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-subscribe --save-dev\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-subscribe');\n```\n\n## The \"subscribe\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `subscribe` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  subscribe: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n});\n```\n\n### Options\n\n#### options.evt\nType: `String`\nDefault value: `'done'`\n\nA string value that is used specify an event to listen for.\n\n#### options.callback\nType: `Function`\nDefault value: `null`\n\nA callback function that is used to do something when target event occurs.\n\n### Usage Examples\n\n#### Default Options\nIn this example, the default options are used. So the event which `grunt-subscribe` will listen to will be – `done`, and since there is no callback provided, you must add event handler function manually inside of your Gruntfile.\n\n```js\ngrunt.initConfig({\n  subscribe: {\n    options: {},\n    test: {}\n  },\n});\n\ngrunt.on('done', function () {\n  // Do something\n});\n```\n\n#### Custom Options\nIn this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`\n\n```js\ngrunt.initConfig({\n  subscribe: {\n    options: {\n      evt: 'New Year',\n      cb: function () {\n        grunt.log.writeln('Happy New Year!!!');\n      },\n    },\n    test: {}\n  },\n});\n```\n\n#### Tasks queue\nGrunt-subscribe also provides an `queue` argument, passing to callback function. This argument contains current task queue and may be used for task completion checks.\n\n```js\ngrunt.initConfig({\n  subscribe: {\n    options: {\n      evt: 'New Year',\n      cb: function (queue) {\n        grunt.log.writeln('queue:', queue); // =\u003e will output something like: queue: [ { placeholder: true } ]\n      },\n    },\n    test: {}\n  },\n});\n```\n\n#### Examples\nIn the example below shown usage of `grunt-subscribe` for notifications when previous tasks has been complete.\n\n```js\ngrunt.initConfig({\n  jshint: {\n    options: {\n      jshintrc: '.jshintrc'\n    },\n    all: [\n      'Gruntfile.js',\n      'tasks/*.js',\n      '\u003c%= nodeunit.tests %\u003e'\n    ]\n  },\n  nodeunit: {\n    tests: ['test/*_test.js']\n  },\n  subscribe: {\n    options: {\n      evt: 'all done',\n      cb: function () {\n        grunt.log.writeln('jshint task completed, nodeunit is about to start...');\n      },\n    },\n    dev: {}\n  },\n});\n\ngrunt.loadNpmTasks('grunt-contrib-jshint');\ngrunt.loadNpmTasks('grunt-contrib-nodeunit');\ngrunt.loadNpmTasks('grunt-subscribe');\n\ngrunt.registerTask('run', ['jshint:all', 'subscribe:dev', 'nodeunit']);\n```\n\n## Release History\n* 2016-02-11   v0.1.0   First official release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycoda%2Fgrunt-subscribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappycoda%2Fgrunt-subscribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycoda%2Fgrunt-subscribe/lists"}