Skip to content

Commit e014a24

Browse files
committed
Reporting
1 parent 6ec072a commit e014a24

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

lib/build-bundler.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ let { promisify } = require("util");
66
let readFile = promisify(fs.readFile);
77
let readdir = promisify(fs.readdir);
88

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

@@ -20,7 +20,12 @@ module.exports = ({ source, target, fingerprint }) => {
2020

2121
let targetPath = path.join(target, fileName);
2222

23-
return createFile(targetPath, content);
23+
return createFile(targetPath, content).then(_ => {
24+
return {
25+
changed: true,
26+
output: path.relative(configDir, targetPath)
27+
};
28+
});
2429
});
2530
}));
2631
});

lib/build-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function translateBundlerConfigs(bundleConfigs, options) {
2222
let target = path.resolve(configDir, bundleConfig.target);
2323

2424
return {
25+
configDir,
2526
fingerprint,
2627
source,
2728
target

lib/build-reporter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// A reporter
2+
//
3+
// Reports the results of the run
4+
module.exports = _ => {
5+
return results => {
6+
results.reduce((acc, cur) => acc.concat(cur)).forEach(res => {
7+
if(res.changed) {
8+
console.log(`✓ ${res.output}`); // eslint-disable-line no-console
9+
}
10+
});
11+
};
12+
};

lib/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let buildConfig = require("./build-config");
22
let buildBundler = require("./build-bundler");
3+
let buildReporter = require("./build-reporter");
34

45
module.exports = (rawConfig, configDir, { watcher, fingerprint }) => {
56
let config = buildConfig(rawConfig, configDir, fingerprint);
@@ -15,10 +16,10 @@ module.exports = (rawConfig, configDir, { watcher, fingerprint }) => {
1516

1617
function buildBundleAll(config) {
1718
let bundlers = config.bundles.map(bundleConfig => buildBundler(bundleConfig));
19+
let report = buildReporter();
1820

1921
return files => {
20-
Promise.all(bundlers.map(bundler => bundler(files)));
22+
Promise.all(bundlers.map(bundler => bundler(files))).then(report);
2123
};
2224
// TODO: Manifest
23-
// TODO: Reporter
2425
}

0 commit comments

Comments
 (0)