-
Notifications
You must be signed in to change notification settings - Fork 40
/
gulpfile.js
150 lines (127 loc) · 3.96 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
var gulp = require('gulp');
var notify = require('../');
var through = require('through2');
var path = require('path');
var plumber = require('gulp-plumber');
var nn = require('node-notifier');
gulp.task("multiple", function () {
gulp.src("../test/fixtures/*")
.pipe(notify());
});
gulp.task("one", function () {
return gulp.src("../test/fixtures/1.txt")
.pipe(notify());
});
notify.on('click', function (options) {
console.log('I clicked something!', options);
});
gulp.task("click", function () {
// Click event only makes sense if wait is true...
return gulp.src("../test/fixtures/1.txt")
.pipe(notify({ message: 'Hello 1', wait: true }));
});
gulp.task("message", function () {
return gulp.src("../test/fixtures/1.txt")
.pipe(notify("This is a message."));
});
gulp.task("customReporter", function () {
var custom = notify.withReporter(function (options, callback) {
console.log("Title:", options.title);
console.log("Message:", options.message);
callback();
});
return gulp.src("../test/fixtures/1.txt")
.pipe(custom("This is a message."));
});
gulp.task("template", function () {
return gulp.src("../test/fixtures/1.txt")
.pipe(notify("Template: <%= file.relative %>"));
});
gulp.task("templateadv", function () {
return gulp.src("../test/fixtures/1.txt")
.pipe(notify({
message: "Template: <%= file.relative %>",
title: function (file) {
if(file.isNull()) {
return "Folder:";
}
return "File: <%= file.relative %> <%= options.extra %>";
},
templateOptions: {
extra: "foo"
}
}));
});
gulp.task("function", function () {
return gulp.src("../test/fixtures/1.txt")
.pipe(notify(function(file) {
return "Some file: " + file.relative;
}));
});
gulp.task("advanced", function () {
return gulp.src("../test/fixtures/*")
.pipe(notify({
"title": "Open Github",
"subtitle": "Project web site",
"message": "Click to open project site",
"sound": "Frog", // case sensitive
"icon": path.join(__dirname, "gulp.png"), // case sensitive
"onLast": true,
"wait": true
}));
});
gulp.task("onlast", function () {
return gulp.src("../test/fixtures/*")
.pipe(notify({
onLast: true,
message: function(file) {
return "Some file: " + file.relative;
}
}));
});
gulp.task("error", function () {
return gulp.src("../test/fixtures/*")
.pipe(through.obj(function (file, enc, callback) {
this.emit("error", new Error("Something happend: Error message!"));
callback();
}))
.on("error", notify.onError({
message: 'Error: <%= error.message %>',
sound: false // deactivate sound?
}))
.on("error", function (err) {
console.log("Error:", err);
})
});
gulp.task("forceGrowl", function () {
var custom = notify.withReporter(function (options, callback) {
new nn.Growl().notify(options, callback);
});
return gulp.src("../test/fixtures/*")
.pipe(through.obj(function (file, enc, callback) {
this.emit("error", new Error("Something happend: Error message!"));
callback();
}))
.on("error", custom.onError('Error: <%= error.message %>'));
});
gulp.task("customError", function () {
var custom = notify.withReporter(function (options, callback) {
console.log("Title:", options.title);
console.log("Message:", options.message);
callback();
});
custom.logLevel(1);
return gulp.src("../test/fixtures/*")
.pipe(custom('<%= file.relative %>'))
.pipe(through.obj(function (file, enc, callback) {
this.emit("error", new Error("Something happend: Error message!"));
callback();
}))
.on("error", custom.onError({
message: 'Error: <%= error.message %>',
emitError: true
}))
.on("error", function (err) {
console.log("Error:", err);
})
});