{"action":"closed","issue":{"url":"https://api.github.com/repos/gulpjs/gulp/issues/1138","labels_url":"https://api.github.com/repos/gulpjs/gulp/issues/1138/labels{/name}","comments_url":"https://api.github.com/repos/gulpjs/gulp/issues/1138/comments","events_url":"https://api.github.com/repos/gulpjs/gulp/issues/1138/events","html_url":"https://github.com/gulpjs/gulp/issues/1138","id":93135024,"number":1138,"title":"Dependency headache - race condition","user":{"login":"gavD","id":205245,"avatar_url":"https://avatars.githubusercontent.com/u/205245?v=3","gravatar_id":"","url":"https://api.github.com/users/gavD","html_url":"https://github.com/gavD","followers_url":"https://api.github.com/users/gavD/followers","following_url":"https://api.github.com/users/gavD/following{/other_user}","gists_url":"https://api.github.com/users/gavD/gists{/gist_id}","starred_url":"https://api.github.com/users/gavD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavD/subscriptions","organizations_url":"https://api.github.com/users/gavD/orgs","repos_url":"https://api.github.com/users/gavD/repos","events_url":"https://api.github.com/users/gavD/events{/privacy}","received_events_url":"https://api.github.com/users/gavD/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-05T18:47:21Z","updated_at":"2015-07-05T19:46:13Z","closed_at":"2015-07-05T19:46:12Z","body":"I have the following:\r\n\r\n```javascript\r\ngulp.task('clean', function(cb) {\r\n  return del(['build/*'], cb);\r\n});\r\n\r\n// ...\r\n\r\ngulp.task('build', ['clean', 'quality', 'styles', 'scripts'], function() {\r\n  // do stuff\r\n});\r\n```\r\n\r\nWhat I need is for \"clean\" to COMPLETELY COMPLETE before \"quality\", \"styles\" and \"scripts\" runs. Unfortunately, they all kick off in parallel, and half the time my build fails because it's still in the middle of clearing the build directory when the unit tests start in `quality`. Race condition.\r\n\r\nI've pored through the Gulp docs and endless articles and I'm still none the wiser; I know that `build` won't start until `['clean', 'quality', 'styles', 'scripts']` have ALL completed and that's great, but `quality`, `styles` and `scripts` should wait for `clean`.\r\n\r\n## Possible solution 1\r\n\r\nI make \"clean\" a dependency on `quality`, `styles` and `scripts`, and that would have the desired effect, but what if I wanted to run, say, `styles` on its own? It would clobber the styles AND scripts in the build directory... Is that something I just have to live with? That I can't run the subtasks in isolation any more if I take this approach?\r\n\r\n## Possible solution 2\r\n\r\nEach of `styles` and `scripts` would have a dependency - `clean-styles` and `clean-scripts` - this would mean that it only cleaned up its own directory first.\r\n\r\nThis would work but it feels less elegant than \"blow away the entire build directory before we start a full build\"\r\n\r\n\r\n\r\nSo, is there any way to have a dependency act like \"hold the phones! Don't do ANYTHING until `clean` is completed\"?\r\n\r\nThanks!\r\n"}}