1 |
|
2 | var gulp = require('gulp');
|
3 | var notify = require('../');
|
4 | var through = require('through2');
|
5 | var plumber = require('gulp-plumber');
|
6 | var nn = require('node-notifier');
|
7 |
|
8 | gulp.task("multiple", function () {
|
9 | gulp.src("../test/fixtures/*")
|
10 | .pipe(notify());
|
11 | });
|
12 |
|
13 | gulp.task("one", function () {
|
14 | gulp.src("../test/fixtures/1.txt")
|
15 | .pipe(notify());
|
16 | });
|
17 |
|
18 | gulp.task("message", function () {
|
19 | gulp.src("../test/fixtures/1.txt")
|
20 | .pipe(notify("This is a message."));
|
21 | });
|
22 |
|
23 |
|
24 | gulp.task("customReporter", function () {
|
25 | var custom = notify.withReporter(function (options, callback) {
|
26 | console.log("Title:", options.title);
|
27 | console.log("Message:", options.message);
|
28 | callback();
|
29 | });
|
30 |
|
31 | gulp.src("../test/fixtures/1.txt")
|
32 | .pipe(custom("This is a message."));
|
33 | });
|
34 |
|
35 | gulp.task("template", function () {
|
36 | gulp.src("../test/fixtures/1.txt")
|
37 | .pipe(notify("Template: <%= file.relative %>"));
|
38 | });
|
39 |
|
40 |
|
41 | gulp.task("templateadv", function () {
|
42 | gulp.src("../test/fixtures/1.txt")
|
43 | .pipe(notify({
|
44 | message: "Template: <%= file.relative %>",
|
45 | title: function (file) {
|
46 | if(file.isNull()) {
|
47 | return "Folder:";
|
48 | }
|
49 | return "File: <%= file.relative %> <%= options.extra %>";
|
50 | },
|
51 | templateOptions: {
|
52 | extra: "foo"
|
53 | }
|
54 | }));
|
55 | });
|
56 |
|
57 | gulp.task("function", function () {
|
58 | gulp.src("../test/fixtures/1.txt")
|
59 | .pipe(notify(function(file) {
|
60 | return "Some file: " + file.relative;
|
61 | }));
|
62 | });
|
63 |
|
64 | gulp.task("onlast", function () {
|
65 | gulp.src("../test/fixtures/*")
|
66 | .pipe(notify({
|
67 | onLast: true,
|
68 | message: function(file) {
|
69 | return "Some file: " + file.relative;
|
70 | }
|
71 | }));
|
72 | });
|
73 |
|
74 | gulp.task("error", function () {
|
75 | gulp.src("../test/fixtures/*")
|
76 | .pipe(through.obj(function (file, enc, callback) {
|
77 | this.emit("error", new Error("Something happend: Error message!"));
|
78 | callback();
|
79 | }))
|
80 | .on("error", notify.onError('Error: <%= error.message %>'))
|
81 | .on("error", function (err) {
|
82 | console.log("Error:", err);
|
83 | })
|
84 | });
|
85 |
|
86 | gulp.task("forceGrowl", function () {
|
87 | var custom = notify.withReporter(function (options, callback) {
|
88 | new nn.Growl().notify(options, callback);
|
89 | });
|
90 |
|
91 | gulp.src("../test/fixtures/*")
|
92 | .pipe(through.obj(function (file, enc, callback) {
|
93 | this.emit("error", new Error("Something happend: Error message!"));
|
94 | callback();
|
95 | }))
|
96 | .on("error", custom.onError('Error: <%= error.message %>'));
|
97 | });
|
98 |
|
99 | gulp.task("customError", function () {
|
100 |
|
101 | var custom = notify.withReporter(function (options, callback) {
|
102 | console.log("Title:", options.title);
|
103 | console.log("Message:", options.message);
|
104 | callback();
|
105 | });
|
106 |
|
107 | custom.logLevel(1);
|
108 |
|
109 | gulp.src("../test/fixtures/*")
|
110 | .pipe(custom('<%= file.relative %>'))
|
111 | .pipe(through.obj(function (file, enc, callback) {
|
112 | this.emit("error", new Error("Something happend: Error message!"));
|
113 | callback();
|
114 | }))
|
115 | .on("error", custom.onError({
|
116 | message: 'Error: <%= error.message %>',
|
117 | emitError: true
|
118 | }))
|
119 | .on("error", function (err) {
|
120 | console.log("Error:", err);
|
121 | })
|
122 | });
|