Skip to content

Commit ef16a33

Browse files
committed
first commit
0 parents  commit ef16a33

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Marcos Paulo dos Santos
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# gulp-tasklist-run
2+
Gulp task list run synchronous.
3+
4+
## Installation
5+
6+
```shell
7+
npm install --save gulp-tasklist-run
8+
```
9+
10+
## How to use
11+
12+
Here is the demo code:
13+
14+
```js
15+
var gulp = require('gulp');
16+
const TaskList = require('gulp-tasklist');
17+
const TaskListRun = require('gulp-tasklist-run');
18+
19+
gulp.task('compile:typescript', [], function () {
20+
// ...
21+
});
22+
23+
gulp.task('e2e:demo', [], function () {
24+
// ...
25+
});
26+
27+
gulp.task('e2e:test', [], function () {
28+
// ...
29+
});
30+
31+
gulp.task('e2e:login', [], function () {
32+
// ...
33+
});
34+
35+
gulp.task('e2e:menu', [], function () {
36+
// ..
37+
});
38+
39+
gulp.task('e2e:sec', [], function () {
40+
// ..
41+
});
42+
```
43+
44+
Just require `gulp-tasklist-run` package and call `run()` method, it receives three parameter, the result of getList(gulp-tasklist), the inclusion(use starts with) and the excluded tasks.
45+
Sample:
46+
47+
```javascript
48+
gulp.task('e2e:*', function() {
49+
50+
let tasks = TaskList.getList('./gulpfile.js');
51+
52+
TaskListRun.run(tasks, 'e2e:', 'e2e:*,e2e:test,e2e:demo');
53+
});
54+
55+
//> Executing task: node_modules\.bin\gulp.cmd e2e:* <
56+
//
57+
//[15:26:00] Using gulpfile c:\GIT\master\gulpfile.js
58+
//[15:26:00] Starting 'e2e:*'...
59+
//[15:26:00] Finished 'e2e:*' after 13 ms
60+
//[15:26:00] Starting 'e2e:sec'...
61+
//[15:26:00] Finished 'e2e:sec' after 91 μs
62+
//[15:26:00] Starting 'e2e:menu'...
63+
//[15:26:00] Finished 'e2e:menu' after 31 μs
64+
//[15:26:00] Starting 'e2e:login'...
65+
//[15:26:00] Finished 'e2e:login' after 23 μs
66+
//
67+
//Terminal will be reused by tasks, press any key to close it.
68+
```
69+
70+
## License
71+
72+
MIT
73+
74+

index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
var gulp = require('gulp');
2+
3+
module.exports = {
4+
run(tasklist, inclusion, exclusions) {
5+
var tasks = [];
6+
forEach(tasklist.data, inclusion, exclusions, function (key){
7+
tasks.push(function (pTasks, pos){
8+
gulp.start(key, function(){
9+
run(pTasks, pos)
10+
});
11+
});
12+
});
13+
if(tasks.length > 0)
14+
tasks[tasks.length - 1].call(null, tasks, tasks.length - 1);
15+
}
16+
};
17+
18+
function forEach(obj, inclusion, exclusions, fn){
19+
var key;
20+
for (key in obj) {
21+
if (exec(fn, key) === false) {
22+
break;
23+
}
24+
}
25+
function exec(fn, key){
26+
if(!key.startsWith(inclusion)
27+
|| exclusions.includes(key))
28+
return true;
29+
return fn.call(null, key);
30+
}
31+
return forEach;
32+
};
33+
34+
function run(tasks, pos){
35+
pos--;
36+
if(pos >= 0)
37+
tasks[pos].call(null, tasks, pos);
38+
};

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "gulp-tasklist-run",
3+
"version": "1.0.0",
4+
"description": "Gulp task list run synchronous.",
5+
"main": "index.js",
6+
"dependencies": {
7+
"gulp": "^3.0.0"
8+
},
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/marcospds/gulp-tasklist-run.git"
15+
},
16+
"keywords": [
17+
"gulp",
18+
"tasks",
19+
"synchronous",
20+
"list"
21+
],
22+
"author": "Marcos Paulo dos Santos <[email protected]>",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/marcospds/gulp-tasklist-run/issues"
26+
},
27+
"homepage": "https://github.com/marcospds/gulp-tasklist-run#readme"
28+
}

0 commit comments

Comments
 (0)