Skip to content

Commit e55721a

Browse files
committed
Support Fingerprinting
1 parent 4807bce commit e55721a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/build-bundler.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
let fs = require("fs");
22
let path = require("path");
3-
let { createFile } = require("faucet-pipeline-util");
3+
let { createFile, generateFingerprint } = require("faucet-pipeline-util");
44
// TODO: Not available on all supported Node versions
55
let { promisify } = require("util");
66
let readFile = promisify(fs.readFile);
77
let readdir = promisify(fs.readdir);
88

9-
module.exports = ({ source, target }) => {
9+
module.exports = ({ source, target, fingerprint }) => {
1010
// TODO: Only copy changed files
1111
return _ => {
1212
readdir(source).then(sources => {
1313
return Promise.all(sources.map(filePath => {
1414
let sourcePath = path.join(source, filePath);
15-
let targetPath = path.join(target, filePath);
1615

1716
return readFile(sourcePath).then(content => {
17+
if(fingerprint) {
18+
filePath = generateFingerprint(filePath, content);
19+
}
20+
21+
let targetPath = path.join(target, filePath);
22+
1823
return createFile(targetPath, content);
1924
});
2025
}));

test/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ begin "./test_basic"
5757
faucet --no-fingerprint
5858
assert_identical "./dist/test.txt" "./src/test.txt"
5959
end
60+
61+
# Once again with fingerprinting
62+
begin "./test_basic"
63+
faucet
64+
assert_identical "./dist/test-e59ff97941044f85df5297e1c302d260.txt" "./src/test.txt"
65+
end

0 commit comments

Comments
 (0)