-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathindex.js
72 lines (60 loc) · 1.82 KB
/
index.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
import transformStream from "easy-transform-stream";
import Revisioner from "./revisioner.js";
import PluginError from "plugin-error";
var PLUGIN_NAME = "gulp-rev-all";
export default {
revision: function (options) {
var revisioner = new Revisioner(options);
// Feed the RevAll Revisioner with all the files in the stream, don't emit them until all of them have been processed
return transformStream({ objectMode: true },
function (file) {
if (file.isStream()) {
throw new PluginError(PLUGIN_NAME, "Streams not supported!");
}
if (file.isBuffer()) {
revisioner.processFile(file);
}
file.revisioner = revisioner;
},
function () {
revisioner.run();
return Object.values(revisioner.files);
}
);
},
versionFile: function () {
var revisioner;
// Drop any existing files off the stream, push the generated version file
return transformStream({ objectMode: true },
function (file) {
if (!revisioner) {
revisioner = file.revisioner;
}
// Drop any existing files off the stream
},
function () {
if (!revisioner) {
throw new PluginError(PLUGIN_NAME, "revision() must be called first!");
}
return [revisioner.versionFile()];
}
);
},
manifestFile: function () {
var revisioner;
// Drop any existing files off the stream, push the generated manifest file
return transformStream({ objectMode: true },
function (file) {
if (!revisioner) {
revisioner = file.revisioner;
}
},
function () {
if (!revisioner) {
throw new PluginError(PLUGIN_NAME, "revision() must be called first!");
}
return [revisioner.manifestFile()];
}
);
},
};