Verified Commit d46e4a2a authored by Aral Balkan's avatar Aral Balkan
Browse files

Fixes #227 (properly, this time)

parent 9ab545ec
......@@ -4,11 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [14.5.2] - 2020-08-27
### Fixes
- Proper fix for issue #227 (https://source.small-tech.org/site.js/app/-/issues/227, see 14.5.1, below.)
## [14.5.1] - 2020-08-26
### Fixes
- File watches now also work when serving the current directory (without a path specified).
- File watches now also work when serving the current directory (without a path specified). (#227)
## [14.5.0] - 2020-08-26
......
......@@ -1137,19 +1137,7 @@ class Site {
// event, it gets triggered with a 'rename' when a removed/recreated folder
// is affected.) See: https://github.com/paulmillr/chokidar/issues/404#issuecomment-666669336
createFileWatcher () {
// Workaround for #227: https://source.small-tech.org/site.js/app/-/issues/227
//
// If the path to serve is the current path, Chokidar doesn’t pick up changes (e.g., to ./**/*).
// However, it does if a relative path is specified. So, as a workaround, we target
// ../<name of current folder>/**/* instead.
const relativePath = this.pathToServe === '.' ? (() => {
const pathFragments = path.resolve('.').split(path.sep)
const currentDirectoryName = pathFragments[pathFragments.length - 1]
return `../${currentDirectoryName}`
})() : this.pathToServe
const fileWatchPath = `${relativePath.replace(/\\/g, '/')}/**/*`
const fileWatchPath = `${this.pathToServe.replace(/\\/g, '/')}/**/*`
this.app.__fileWatcher = chokidar.watch(fileWatchPath, {
persistent: true,
......@@ -1157,14 +1145,14 @@ class Site {
})
this.app.__fileWatcher.on ('all', (event, file) => {
if (file.includes('/.dynamic')) {
if (file.includes('.dynamic')) {
//
// Dynamic route change.
//
this.log(` 🐁 ❨site.js❩ Dynamic route change: ${clr(`${this.prettyFileWatcherEvent(event)}`, 'green')} (${clr(file, 'cyan')}).`)
this.log('\n 🐁 ❨site.js❩ Requesting restart…\n')
this.restartServer()
} else if (file.includes('/.wildcard')) {
} else if (file.includes('.wildcard')) {
//
// Wildcard route change.
//
......
{
"name": "@small-tech/site.js",
"version": "14.5.1",
"version": "14.5.2",
"description": "Small Web construction set.",
"keywords": [
"web server",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment