Skip to content

Commit

Permalink
Merge pull request #641 from MadeByMike/add-custom-watcher
Browse files Browse the repository at this point in the history
Add addWatchTarget() option to config
  • Loading branch information
zachleat authored Nov 27, 2019
2 parents 2c7bde7 + c887d59 commit c7139b7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
7 changes: 2 additions & 5 deletions .github/ISSUE_TEMPLATE/i-have-a-question-about-eleventy.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
name: I have a question about Eleventy
about: e.g. “How do I do this in Eleventy?” or “Can Eleventy do this?”
title: ''
title: ""
labels: education
assignees: ''

assignees: ""
---


11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/i-m-having-a-problem-with-eleventy.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: I’m having a problem with Eleventy
about: Create a report to help us improve
title: ''
title: ""
labels: needs-triage
assignees: ''

assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,8 +24,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Environment:**
- OS and Version: [e.g. Windows/Mac/Linux]
- Eleventy Version [via `eleventy --version` or `npx @11ty/eleventy --version`]

- OS and Version: [e.g. Windows/Mac/Linux]
- Eleventy Version [via `eleventy --version` or `npx @11ty/eleventy --version`]

**Additional context**
Add any other context about the problem here.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: I want Eleventy do to this new thing
about: Suggest an idea for this project
title: ''
title: ""
labels: enhancement
assignees: ''

assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ sudo: false
os:
- linux
- osx
- windows
- windows
env:
- YARN_GPG=no
3 changes: 1 addition & 2 deletions src/Eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class Eleventy {

/** @member {Object} - tbd. */
this.watchTargets = new EleventyWatchTargets();

/** @member {Object} - tbd. */
this.watchTargets.add(this.config.additionalWatchTargets);
this.watchTargets.watchJavaScriptDependencies = this.config.watchJavaScriptDependencies;
}

Expand Down
6 changes: 6 additions & 0 deletions src/UserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class UserConfig {
// this.userExtensionMap = {};
// this.templateExtensionAliases = {};
this.watchJavaScriptDependencies = true;
this.additionalWatchTargets = [];
this.browserSyncConfig = {};

// using Map to preserve insertion order
Expand Down Expand Up @@ -560,6 +561,10 @@ class UserConfig {
// this.templateExtensionAliases[extension] = targetKey;
// }

addWatchTarget(additionalWatchTargets) {
this.additionalWatchTargets.push(additionalWatchTargets);
}

setWatchJavaScriptDependencies(watchEnabled) {
this.watchJavaScriptDependencies = !!watchEnabled;
}
Expand Down Expand Up @@ -605,6 +610,7 @@ class UserConfig {
experiments: this.experiments,
// templateExtensionAliases: this.templateExtensionAliases,
watchJavaScriptDependencies: this.watchJavaScriptDependencies,
additionalWatchTargets: this.additionalWatchTargets,
browserSyncConfig: this.browserSyncConfig,
frontMatterParsingOptions: this.frontMatterParsingOptions,
dataExtensions: this.dataExtensions
Expand Down
12 changes: 12 additions & 0 deletions test/TemplateConfigTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,15 @@ test("Properly throws error when config returns a Promise", t => {
);
});
});

test(".addWatchTarget adds a watch target", t => {
eleventyConfig.reset();
eleventyConfig.addWatchTarget("/testdirectory/");

let templateCfg = new TemplateConfig(
require("../config.js"),
"./test/stubs/config.js"
);
let cfg = templateCfg.getConfig();
t.deepEqual(cfg.additionalWatchTargets, ["/testdirectory/"]);
});

0 comments on commit c7139b7

Please sign in to comment.