Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addWatchTarget() option to config #641

Merged
merged 9 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -72,8 +72,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
1 change: 0 additions & 1 deletion src/TemplateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const chalk = require("chalk");
const lodashMerge = require("lodash/merge");
const TemplatePath = require("./TemplatePath");
const EleventyBaseError = require("./EleventyBaseError");
const dependencyTree = require("dependency-tree");
const eleventyConfig = require("./EleventyConfig");
const debug = require("debug")("Eleventy:TemplateConfig");

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 = {};
}

Expand Down Expand Up @@ -551,6 +552,10 @@ class UserConfig {
// this.templateExtensionAliases[extension] = targetKey;
// }

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

setWatchJavaScriptDependencies(watchEnabled) {
this.watchJavaScriptDependencies = !!watchEnabled;
}
Expand Down Expand Up @@ -596,6 +601,7 @@ class UserConfig {
experiments: this.experiments,
// templateExtensionAliases: this.templateExtensionAliases,
watchJavaScriptDependencies: this.watchJavaScriptDependencies,
additionalWatchTargets: this.additionalWatchTargets,
browserSyncConfig: this.browserSyncConfig,
frontMatterParsingOptions: this.frontMatterParsingOptions
};
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/"]);
});