-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (47 loc) · 1.2 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
/**
* Copyright (C) 2016 pantojs.xyz
* index.js
*
* changelog
* 2016-06-22[18:25:56]:revised
*
* @author yanni4night@gmail.com
* @version 0.2.4
* @since 0.1.0
*/
'use strict';
const Transformer = require('panto-transformer');
const {
contentstamp
} = require('filestamp');
class StampTransformer extends Transformer {
_transform(file) {
let {
filename,
content
} = file;
const {
ignoreError,
isSilent
} = this.options;
return new Promise((resolve, reject) => {
contentstamp(content, filename, (err, result) => {
if (err) {
if (ignoreError) {
if (!isSilent) {
panto.log.warn(`StampTransform warnning in ${filename}: ${err.message}`);
}
resolve(file);
} else {
reject(err);
}
} else {
resolve(panto._.extend(file, {
stamp: result.filename
}));
}
});
});
}
}
module.exports = StampTransformer;