diff --git a/bin/faucet b/bin/faucet index 6eb573c..79d8496 100755 --- a/bin/faucet +++ b/bin/faucet @@ -1,8 +1,10 @@ #!/usr/bin/env node "use strict"; -let faucet = require("../lib"); -let parseCLI = require("../lib/cli"); +let { faucetDispatch } = require("../lib"); +let { parseCLI } = require("../lib/cli"); -let { referenceDir, config, options } = parseCLI(); -faucet(referenceDir, config, options); +parseCLI(). + then(({ referenceDir, config, options }) => { + faucetDispatch(referenceDir, config, options); + }); diff --git a/lib/cli.js b/lib/cli.js index 8a0156d..01dba5b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,6 +1,6 @@ "use strict"; -let readConfig = require("./config"); +let { readConfig } = require("./config"); let { abort, repr } = require("./util"); let parseArgs = require("minimist"); @@ -27,7 +27,7 @@ Options: serve generated files via HTTP with live reloading `.trim(); -module.exports = function parseCLI(argv = process.argv.slice(2), help = HELP) { +exports.parseCLI = async function parseCLI(argv = process.argv.slice(2), help = HELP) { argv = parseArgs(argv, { boolean: ["watch", "fingerprint", "sourcemaps", "compact"], alias: { @@ -56,6 +56,6 @@ module.exports = function parseCLI(argv = process.argv.slice(2), help = HELP) { } let rootDir = process.cwd(); - let { referenceDir, config } = readConfig(rootDir, argv.config); + let { referenceDir, config } = await readConfig(rootDir, argv.config); return { referenceDir, config, options }; }; diff --git a/lib/config.js b/lib/config.js index f585bc2..b87fa5c 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,10 +2,10 @@ let path = require("path"); -module.exports = function readConfig(rootDir, filepath = "faucet.config.js") { +exports.readConfig = async function readConfig(rootDir, filepath = "faucet.config.js") { let configPath = path.resolve(rootDir, filepath); return { referenceDir: path.dirname(configPath), - config: require(configPath) + config: await require(configPath) }; }; diff --git a/lib/index.js b/lib/index.js index 16d19e3..6606d1f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,13 +2,13 @@ let server = require("./server"); let { pluginsByBucket } = require("./plugins"); -let AssetManager = require("./manager"); -let resolvePath = require("./util/resolve"); +let { AssetManager } = require("./manager"); +let { resolvePath } = require("./util/resolve"); let { abort, repr } = require("./util"); -let SerializedRunner = require("./util/runner"); +let { SerializedRunner } = require("./util/runner"); let browserslist = require("browserslist"); -module.exports = async function faucetDispatch(referenceDir, config, +exports.faucetDispatch = async function faucetDispatch(referenceDir, config, { watch, fingerprint, sourcemaps, compact, serve, liveserve }) { config = await config; @@ -22,7 +22,7 @@ module.exports = async function faucetDispatch(referenceDir, config, browsers = [browsers]; } - let plugins = pluginsByBucket(config); + let plugins = await pluginsByBucket(config); // initialize plugins with corresponding configuration let buckets = Object.keys(plugins).reduce((memo, bucket) => { memo[bucket] = plugins[bucket].map(({ plugin, config }) => { @@ -40,8 +40,10 @@ module.exports = async function faucetDispatch(referenceDir, config, if(watch) { makeWatcher(config.watchDirs, referenceDir). - on("edit", filepaths => { - runner.rerun(filepaths); + then(watcher => { + watcher.on("edit", filepaths => { + runner.rerun(filepaths); + }); }); } @@ -60,8 +62,8 @@ function buildStep(plugins) { then(() => files); } -function makeWatcher(watchDirs, referenceDir) { - let niteOwl = require("nite-owl"); +async function makeWatcher(watchDirs, referenceDir) { + let niteOwl = await require("nite-owl"); if(watchDirs) { watchDirs = watchDirs.map(dir => resolvePath(dir, referenceDir, diff --git a/lib/manager.js b/lib/manager.js index f3e8c23..c75f97a 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -1,12 +1,12 @@ "use strict"; -let Manifest = require("./manifest"); -let createFile = require("./util/files"); -let resolvePath = require("./util/resolve"); +let { Manifest } = require("./manifest"); +let { createFile } = require("./util/files"); +let { resolvePath } = require("./util/resolve"); let { reportFileStatus, abort, generateFingerprint } = require("./util"); let path = require("path"); -module.exports = class AssetManager { +exports.AssetManager = class AssetManager { constructor(referenceDir, { manifestConfig, fingerprint, exitOnError } = {}) { this.referenceDir = referenceDir; this.fingerprint = fingerprint; @@ -30,9 +30,9 @@ module.exports = class AssetManager { } return createFile(filepath, data). - then(_ => this.manifest && + then(() => this.manifest && this._updateManifest(originalPath, filepath, targetDir)). - then(_ => { + then(() => { reportFileStatus(originalPath, this.referenceDir, error); if(error && this.exitOnError) { throw error; diff --git a/lib/manifest.js b/lib/manifest.js index b7985a9..51db3ff 100644 --- a/lib/manifest.js +++ b/lib/manifest.js @@ -1,11 +1,11 @@ "use strict"; -let createFile = require("./util/files"); -let resolvePath = require("./util/resolve"); +let { createFile } = require("./util/files"); +let { resolvePath } = require("./util/resolve"); let { abort } = require("./util"); let path = require("path"); -module.exports = class Manifest { +exports.Manifest = class Manifest { constructor(referenceDir, { target, key, value, baseURI, webRoot } = {}) { if(value && (baseURI || webRoot)) { abort("ERROR: `value` must not be used with `baseURI` and/or `webRoot`"); diff --git a/lib/plugins.js b/lib/plugins.js index 80805e8..b940706 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -33,47 +33,50 @@ module.exports = { // returns plugin functions grouped by bucket and filtered by relevance (based // on configuration) -function pluginsByBucket(config, defaults) { - let plugins = determinePlugins(config.plugins, defaults); +async function pluginsByBucket(config, defaults) { + let plugins = await determinePlugins(config.plugins, defaults); let buckets = [...BUCKETS].reduce((memo, bucket) => { memo[bucket] = []; return memo; }, {}); - Object.entries(plugins).forEach(([key, _plugin]) => { + for(let [key, _plugin] of Object.entries(plugins)) { let pluginConfig = config[key]; if(!pluginConfig) { - return; + continue; } let { bucket, plugin } = _plugin; + if(!plugin.call) { + ({ plugin } = await loadPlugin(plugin)); + } buckets[bucket].push({ - plugin: plugin.call ? plugin : loadPlugin(plugin).plugin, + plugin, config: pluginConfig }); - }); + } return buckets; } // `plugins` is an array of plugins, each either a package identifier or a // `{ key, bucket, plugin }` object`, with `key` being the configuration key and // `plugin` being either a function or a package identifier -function determinePlugins(plugins = [], defaults = DEFAULTS) { +async function determinePlugins(plugins = [], defaults = DEFAULTS) { let registry = {}; // NB: default plugins are resolved lazily because eager loading would // result in them becoming a hard dependency rather than a convenience // preset - however, that requires us to duplicate the respective // configuration keys and buckets here - defaults.forEach(plugin => { - registerPlugin(registry, plugin, false); - }); - plugins.forEach(plugin => { - registerPlugin(registry, plugin, true); - }); + for(let plugin of defaults) { + await registerPlugin(registry, plugin, false); + } + for(let plugin of plugins) { + await registerPlugin(registry, plugin, true); + } return registry; } -function registerPlugin(registry, _plugin, eager) { - let { key, bucket, plugin } = resolvePlugin(_plugin, eager); +async function registerPlugin(registry, _plugin, eager) { + let { key, bucket, plugin } = await resolvePlugin(_plugin, eager); // NB: default plugins may be overridden if(registry[key] && !DEFAULT_KEYS.has(key)) { abort(`ERROR: duplicate plugin key ${repr(key, false)}`); @@ -84,14 +87,14 @@ function registerPlugin(registry, _plugin, eager) { } } -function resolvePlugin(_plugin, eager) { +async function resolvePlugin(_plugin, eager) { if(_plugin.substr) { // package identifier - _plugin = loadPlugin(_plugin); + _plugin = await loadPlugin(_plugin); } let { key, bucket, plugin } = _plugin; if(eager && plugin.substr && (!key || !bucket)) { // auto-configuration - let _plugin = loadPlugin(plugin); + let _plugin = await loadPlugin(plugin); plugin = _plugin.plugin; // local configuration takes precedence key = key || _plugin.key; @@ -104,13 +107,13 @@ function resolvePlugin(_plugin, eager) { return { key, bucket, plugin }; } -function loadPlugin(pkg) { +async function loadPlugin(pkg) { let fail = prop => abort(`ERROR: invalid plugin ${repr(pkg)}; ` + `missing ${repr(prop, false)}`); let { key = fail("key"), bucket = fail("bucket"), plugin = fail("plugin") - } = loadExtension(pkg, "ERROR: missing plugin"); + } = await loadExtension(pkg, "ERROR: missing plugin"); return { key, bucket, plugin }; } diff --git a/lib/server.js b/lib/server.js index 7d3a961..9ecb696 100644 --- a/lib/server.js +++ b/lib/server.js @@ -5,18 +5,16 @@ let DEFAULTS = { port: 3000 }; -exports.static = (config, webroot) => { - let donny = loadExtension("donny", "failed to activate server"); +exports.static = async (config, webroot) => { + let donny = await loadExtension("donny", "failed to activate server"); let [host, port] = parseHost(config); - donny({ port, bind: host, webroot }). - then(() => { - console.error(`serving ${repr(webroot)} at http://${host}:${port}`); - }); + await donny({ port, bind: host, webroot }); + console.error(`serving ${repr(webroot)} at http://${host}:${port}`); }; -exports.live = (config, root) => { - let liveServer = loadExtension("live-server", "failed to activate live-server"); +exports.live = async (config, root) => { + let liveServer = await loadExtension("live-server", "failed to activate live-server"); let [host, port] = parseHost(config); liveServer.start({ port, host, root, open: false }); diff --git a/lib/util/files/finder.js b/lib/util/files/finder.js index 279fc48..2cf86d9 100644 --- a/lib/util/files/finder.js +++ b/lib/util/files/finder.js @@ -1,11 +1,7 @@ -let fs = require("fs"); +let { readdir, stat } = require("fs/promises"); let path = require("path"); -let { promisify } = require("util"); -let stat = promisify(fs.stat); -let readDir = promisify(fs.readdir); - -module.exports = class FileFinder { +exports.FileFinder = class FileFinder { constructor(directory, { skipDotfiles, filter = () => true } = {}) { this.directory = directory; this.filter = filename => { @@ -36,7 +32,7 @@ function tree(filepath, referenceDir = filepath) { return [path.relative(referenceDir, filepath)]; } - return readDir(filepath). + return readdir(filepath). then(entries => { let res = Promise.all(entries.map(entry => { return tree(path.join(filepath, entry), referenceDir); diff --git a/lib/util/files/index.js b/lib/util/files/index.js index 33fb517..f2d8ef0 100644 --- a/lib/util/files/index.js +++ b/lib/util/files/index.js @@ -1,42 +1,29 @@ "use strict"; -let { abort, repr } = require("../"); -let fs = require("fs"); +let { writeFile } = require("fs/promises"); +let { mkdirSync } = require("fs"); let path = require("path"); -let { promisify } = require("util"); -let KNOWN = {}; // avoids redundant `mkdirp` invocations -let LOCKS = {}; - -let writeFile = promisify(fs.writeFile); +let KNOWN = new Set(); // avoids redundant `mkdir` invocations +let LOCKS = new Map(); // avoids concurrent write operations and creates target directory if necessary -module.exports = function createFile(filepath, contents) { - let lock = LOCKS[filepath]; +exports.createFile = function createFile(filepath, contents) { + let lock = LOCKS.get(filepath); if(lock) { // defer - return lock.then(_ => createFile(filepath, contents)); + return lock.then(() => createFile(filepath, contents)); } // create directory if necessary - if(!KNOWN[filepath]) { - KNOWN[filepath] = true; + if(!KNOWN.has(filepath)) { + KNOWN.add(filepath); // NB: `sync` avoids race condition for subsequent operations - mkdirpSync(path.dirname(filepath)); + mkdirSync(path.dirname(filepath), { recursive: true }); } let prom = writeFile(filepath, contents); - LOCKS[filepath] = prom; - return prom.then(_ => { - delete LOCKS[filepath]; + LOCKS.set(filepath, prom); + return prom.then(() => { + LOCKS.delete(filepath); }); }; - -function mkdirpSync(directory) { - try { - // NB: `recursive` option was introduced in Node v10.12.0 - fs.mkdirSync(directory, { recursive: true }); - } catch(err) { - abort(`ERROR: auto-creating ${repr(directory)} requires ` + - "Node v10.12.0 or above"); - } -} diff --git a/lib/util/index.js b/lib/util/index.js index b118ef3..0698bc2 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -2,10 +2,8 @@ let path = require("path"); let crypto = require("crypto"); -let { promisify } = require("util"); exports.abort = abort; -exports.promisify = promisify; // deprecated exports.repr = repr; // reports success or failure for a given file path (typically regarding @@ -15,11 +13,11 @@ exports.reportFileStatus = (filepath, referenceDir, error) => { console.error(error ? `✗ ${ref}: ${error.message || error}` : `✓ ${ref}`); }; -// attempts to `require` a module, prompting the user to install the -// corresponding package if it is unavailable -exports.loadExtension = (pkg, errorMessage, supplier = pkg) => { +// attempts to load a module, prompting the user to install the corresponding +// package if it is unavailable +exports.loadExtension = async (pkg, errorMessage, supplier = pkg) => { try { - return require(pkg); + return await require(pkg); } catch(err) { if(err.code !== "MODULE_NOT_FOUND") { throw err; diff --git a/lib/util/resolve.js b/lib/util/resolve.js index 410e185..afb8124 100644 --- a/lib/util/resolve.js +++ b/lib/util/resolve.js @@ -4,7 +4,8 @@ let { abort, repr } = require("./"); let fs = require("fs"); let path = require("path"); -module.exports = function resolvePath(filepath, referenceDir, { enforceRelative } = {}) { +exports.resolvePath = function resolvePath(filepath, referenceDir, + { enforceRelative } = {}) { if(/^\.?\.\//.test(filepath)) { // starts with `./` or `../` return path.resolve(referenceDir, filepath); } else if(enforceRelative) { diff --git a/lib/util/runner.js b/lib/util/runner.js index 2b75e5c..90ec0af 100644 --- a/lib/util/runner.js +++ b/lib/util/runner.js @@ -1,6 +1,6 @@ "use strict"; -module.exports = class SerializedRunner { +exports.SerializedRunner = class SerializedRunner { constructor(asyncOp) { this.asyncOp = asyncOp; } @@ -8,7 +8,7 @@ module.exports = class SerializedRunner { run(...args) { if(!this._pending) { // prevent concurrent execution this._pending = augment(this.asyncOp(...args)). - finally(_ => { + finally(() => { this._pending = null; }); } @@ -25,10 +25,10 @@ module.exports = class SerializedRunner { let res = this.run(...args); if(enqueue) { this._queued = res = augment(res). - finally(_ => { + finally(() => { this._queued = null; }). - then(_ => this.run(...args)); + then(() => this.run(...args)); } return res; } diff --git a/test/test_manager.js b/test/test_manager.js index 883ad9c..9966e48 100644 --- a/test/test_manager.js +++ b/test/test_manager.js @@ -1,13 +1,13 @@ /* global describe, before, after, it */ "use strict"; -let AssetManager = require("../lib/manager"); +let { AssetManager } = require("../lib/manager"); let path = require("path"); let assert = require("assert"); let assertSame = assert.strictEqual; -describe("asset manager", _ => { +describe("asset manager", () => { let root = path.resolve(__dirname, "fixtures"); let cwd; let { exit } = process; diff --git a/test/test_manifest.js b/test/test_manifest.js index f4fa43a..e175209 100644 --- a/test/test_manifest.js +++ b/test/test_manifest.js @@ -1,13 +1,13 @@ /* global describe, before, after, it */ "use strict"; -let Manifest = require("../lib/manifest"); +let { Manifest } = require("../lib/manifest"); let path = require("path"); let assert = require("assert"); let assertSame = assert.strictEqual; -describe("manifest", _ => { +describe("manifest", () => { let root = path.resolve(__dirname, "fixtures"); let cwd; @@ -23,18 +23,18 @@ describe("manifest", _ => { it("maps original to actual file names with deterministic serialization", () => { let manifest = new Manifest(root); return manifest.set("foo.png", "foo-abc123.png"). - then(_ => { + then(() => { assertSame(JSON.stringify(manifest), '{"foo.png":"/foo-abc123.png"}'); return manifest.set("bar.css", "bar-def456.css"); }). - then(_ => { + then(() => { assertSame(JSON.stringify(manifest), '{"bar.css":"/bar-def456.css","foo.png":"/foo-abc123.png"}'); return manifest.set("xox.js", "xox-ghi789.js"); }). - then(_ => { + then(() => { assertSame(JSON.stringify(manifest), // eslint-disable-next-line max-len '{"bar.css":"/bar-def456.css","foo.png":"/foo-abc123.png","xox.js":"/xox-ghi789.js"}'); }); diff --git a/test/test_plugins.js b/test/test_plugins.js index 259dfe3..104631d 100644 --- a/test/test_plugins.js +++ b/test/test_plugins.js @@ -30,7 +30,7 @@ let DEFAULTS = { let { NODE_PATH } = process.env; let CUSTOM_NODE_PATH = path.resolve(ROOT, "node_modules"); -describe("plugin registration", _ => { +describe("plugin registration", () => { before(() => { updateNodePath(NODE_PATH, CUSTOM_NODE_PATH); }); @@ -39,8 +39,8 @@ describe("plugin registration", _ => { updateNodePath(NODE_PATH); }); - it("only loads default plugins referenced within configuration", () => { - let res = pluginsByBucket({ + it("only loads default plugins referenced within configuration", async () => { + let res = await pluginsByBucket({ js: [{ foo: "lorem" }] }); assertDeep(normalizeAll(res), { @@ -53,7 +53,7 @@ describe("plugin registration", _ => { markup: [] }); - res = pluginsByBucket({ + res = await pluginsByBucket({ sass: [{ bar: "ipsum" }] }); assertDeep(normalizeAll(res), { @@ -66,7 +66,7 @@ describe("plugin registration", _ => { markup: [] }); - res = pluginsByBucket({ + res = await pluginsByBucket({ js: [{ foo: "lorem" }], sass: [{ bar: "ipsum" }] }); @@ -84,8 +84,8 @@ describe("plugin registration", _ => { }); }); - it("allows overriding default plugins", () => { - let res = pluginsByBucket({ + it("allows overriding default plugins", async () => { + let res = await pluginsByBucket({ js: [{ foo: "bar" }], plugins: [{ key: "js", @@ -105,7 +105,7 @@ describe("plugin registration", _ => { }); }); -describe("plugin resolution", _ => { +describe("plugin resolution", () => { let { exit } = process; before(() => { @@ -120,12 +120,12 @@ describe("plugin resolution", _ => { updateNodePath(NODE_PATH); }); - it("provides a default set of plugins", () => { - let res = _determinePlugins(); + it("provides a default set of plugins", async () => { + let res = await _determinePlugins(); assertDeep(normalizePlugins(res), DEFAULTS); }); - it("supports custom plugins", () => { + it("supports custom plugins", async () => { // plugin function within configuration let anon = () => {}; let config = [{ @@ -133,7 +133,7 @@ describe("plugin resolution", _ => { bucket: "static", plugin: anon }]; - let res = _determinePlugins(config); + let res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -144,7 +144,7 @@ describe("plugin resolution", _ => { // nested package identifier let pkg = "faucet-pipeline-dummy"; config[0].plugin = pkg; - res = _determinePlugins(config); + res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -154,7 +154,7 @@ describe("plugin resolution", _ => { })); // simple package identifier - res = _determinePlugins([pkg]); + res = await _determinePlugins([pkg]); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { dummy: { bucket: "static", @@ -163,12 +163,12 @@ describe("plugin resolution", _ => { })); }); - it("allows overriding plugins' default configuration", () => { + it("allows overriding plugins' default configuration", async () => { let config = [{ key: "yummy", plugin: "faucet-pipeline-dummy" }]; - let res = _determinePlugins(config); + let res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { yummy: { bucket: "static", @@ -177,7 +177,7 @@ describe("plugin resolution", _ => { })); config[0].bucket = "styles"; - res = _determinePlugins(config); + res = await _determinePlugins(config); assertDeep(normalizePlugins(res), Object.assign({}, DEFAULTS, { yummy: { bucket: "styles", @@ -188,12 +188,12 @@ describe("plugin resolution", _ => { }); it("balks at invalid package identifiers", () => { - assert.throws(() => { - _determinePlugins(["faucet-pipeline-yummy"]); + assert.rejects(async () => { + return _determinePlugins(["faucet-pipeline-yummy"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins([{ + assert.rejects(() => { + return _determinePlugins([{ // NB: local configuration must not be comprehensive to ensure // plugin is loaded key: "yummy", @@ -203,8 +203,8 @@ describe("plugin resolution", _ => { }); it("balks at duplicate configuration keys", () => { - assert.throws(() => { - _determinePlugins([{ + assert.rejects(() => { + return _determinePlugins([{ key: "dummy", bucket: "static", plugin: () => {} @@ -217,16 +217,16 @@ describe("plugin resolution", _ => { }); it("balks at invalid plugins", () => { - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-a"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-a"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-b"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-b"]); }, /exit 1/); - assert.throws(() => { - _determinePlugins(["faucet-pipeline-invalid-c"]); + assert.rejects(() => { + return _determinePlugins(["faucet-pipeline-invalid-c"]); }, /exit 1/); }); @@ -237,14 +237,14 @@ describe("plugin resolution", _ => { }; ["static", "scripts", "styles", "markup"].forEach(bucket => { plugin.bucket = bucket; - assert.doesNotThrow(() => { - _determinePlugins([plugin]); + assert.doesNotReject(() => { + return _determinePlugins([plugin]); }, /exit 1/); }); plugin.bucket = "dummy"; - assert.throws(() => { - _determinePlugins([plugin]); + assert.rejects(() => { + return _determinePlugins([plugin]); }, /exit 1/); }); }); diff --git a/test/test_runner.js b/test/test_runner.js index 93694e6..bf5a621 100644 --- a/test/test_runner.js +++ b/test/test_runner.js @@ -1,10 +1,10 @@ /* global describe, it */ "use strict"; -let SerializedRunner = require("../lib/util/runner"); +let { SerializedRunner } = require("../lib/util/runner"); let { strictEqual: assertSame, deepStrictEqual: assertDeep } = require("assert"); -describe("watch mode", _ => { +describe("watch mode", () => { it("avoids concurrent compilation, queueing recompilation", () => { let bundle = new MockBundle(); @@ -13,7 +13,7 @@ describe("watch mode", _ => { bundle.compile(); // skipped due to queue limit let prevLog; // keeps track of compilation sequence return bundle.compile(). // skipped due to queue limit - then(_ => { + then(() => { let log = bundle.executionLog; assertSame(log.length, 2); // compiled, then recompiled once prevLog = [].concat(log); @@ -23,7 +23,7 @@ describe("watch mode", _ => { bundle.compile(); // skipped due to queue limit return bundle.compile(); // skipped due to queue limit }). - then(_ => { + then(() => { let log = bundle.executionLog; assertSame(log.length, 4); // compiled, then recompiled once assertDeep(log.slice(0, prevLog.length), prevLog); @@ -31,7 +31,7 @@ describe("watch mode", _ => { return bundle.compile(); // starts compilation }). - then(_ => { + then(() => { let log = bundle.executionLog; assertSame(log.length, 5); assertDeep(log.slice(0, prevLog.length), prevLog); @@ -57,7 +57,7 @@ class MockBundle { _compile(id) { return wait(1). - then(_ => { + then(() => { if(id) { this.executionLog.push(id); } @@ -67,6 +67,6 @@ class MockBundle { function wait(delay) { return new Promise(resolve => { - setTimeout(_ => { resolve(); }, delay); + setTimeout(() => { resolve(); }, delay); }); } diff --git a/test/test_server.js b/test/test_server.js index f1de90c..e7f77a4 100644 --- a/test/test_server.js +++ b/test/test_server.js @@ -6,7 +6,7 @@ let assert = require("assert"); let assertSame = assert.strictEqual; -describe("server host parsing", _ => { +describe("server host parsing", () => { let { exit } = process; before(() => { diff --git a/test/test_util.js b/test/test_util.js index 7bc251f..06f06e0 100644 --- a/test/test_util.js +++ b/test/test_util.js @@ -2,7 +2,7 @@ "use strict"; let { generateFingerprint } = require("../lib/util"); -let FileFinder = require("../lib/util/files/finder"); +let { FileFinder } = require("../lib/util/files/finder"); let path = require("path"); let assert = require("assert"); @@ -11,7 +11,7 @@ let assertDeep = assert.deepStrictEqual; let FIXTURES_PATH = path.resolve(__dirname, "fixtures"); -describe("fingerprinting", _ => { +describe("fingerprinting", () => { it("generates a content-dependent hash", () => { let fingerprint = generateFingerprint("/path/to/foo.js", "lorem ipsum"); assertSame(fingerprint, "/path/to/foo-80a751fde577028640c419000e33eba6.js"); @@ -26,7 +26,7 @@ describe("fingerprinting", _ => { }); }); -describe("FileFinder", _ => { +describe("FileFinder", () => { it("finds all files within a folder", () => { let fileFinder = new FileFinder(FIXTURES_PATH);