Skip to content

Commit 85af017

Browse files
committed
Clean up
1 parent c9c4c9f commit 85af017

File tree

3 files changed

+16
-37
lines changed

3 files changed

+16
-37
lines changed

lib/cli.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
22

3-
let { readConfig } = require("./config");
43
let { abort, repr } = require("./util");
54
let { parseArgs } = require("node:util");
5+
let path = require("node:path");
66

77
let HELP = `
88
Usage:
@@ -37,7 +37,8 @@ exports.parseCLI = async function parseCLI() {
3737
},
3838
config: {
3939
type: "string",
40-
short: "c"
40+
short: "c",
41+
default: "faucet.config.js"
4142
},
4243
watch: {
4344
type: "boolean",
@@ -69,21 +70,10 @@ exports.parseCLI = async function parseCLI() {
6970
abort(HELP, 0);
7071
}
7172

72-
let options = {
73-
watch: values.watch,
74-
fingerprint: values.fingerprint,
75-
sourcemaps: values.sourcemaps,
76-
compact: values.compact,
77-
serve: values.serve,
78-
liveserve: values.liveserve
73+
let configPath = path.resolve(process.cwd(), values.config);
74+
return {
75+
referenceDir: path.dirname(configPath),
76+
config: await require(configPath),
77+
options: values
7978
};
80-
81-
if(options.watch && options.fingerprint) { // for convenience
82-
console.error("you might consider disabling fingerprinting in watch " +
83-
"mode to avoid littering your file system with obsolete bundles");
84-
}
85-
86-
let rootDir = process.cwd();
87-
let { referenceDir, config } = await readConfig(rootDir, values.config);
88-
return { referenceDir, config, options };
8979
};

lib/config.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ let { SerializedRunner } = require("./runner");
88

99
exports.faucetDispatch = async function faucetDispatch(referenceDir, config,
1010
{ watch, fingerprint, sourcemaps, compact, serve, liveserve }) {
11-
config = await config;
12-
1311
let assetManager = new AssetManager(referenceDir, {
1412
manifestConfig: config.manifest,
1513
fingerprint,
@@ -33,12 +31,14 @@ exports.faucetDispatch = async function faucetDispatch(referenceDir, config,
3331
runner.run();
3432

3533
if(watch) {
36-
makeWatcher(config.watchDirs, referenceDir).
37-
then(watcher => {
38-
watcher.on("edit", filepaths => {
39-
runner.rerun(filepaths);
40-
});
41-
});
34+
if(fingerprint) {
35+
console.error("you might consider disabling fingerprinting in watch " +
36+
"mode to avoid littering your file system with obsolete bundles");
37+
}
38+
let watcher = await makeWatcher(config.watchDirs, referenceDir);
39+
watcher.on("edit", filepaths => {
40+
runner.rerun(filepaths);
41+
});
4242
}
4343

4444
if(serve && liveserve) {

0 commit comments

Comments
 (0)