Skip to content

Commit

Permalink
fixed ignored dotfiles #419
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed May 9, 2023
1 parent 1c55089 commit 2621c5d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Any BREAKING CHANGE between minor versions will be documented here in upper case
- The `deno task lume init` command.
Since Lume cannot be installed globally, it doesn't make sense any more.

### Fixed
- Dot files mustn't be ignored [#419].

## [1.17.1] - 2023-05-08
### Fixed
- Changes on static files deletes the file from `_site` [#418].
Expand Down Expand Up @@ -2219,6 +2222,7 @@ The first version.
[#413]: https://github.com/lumeland/lume/issues/413
[#417]: https://github.com/lumeland/lume/issues/417
[#418]: https://github.com/lumeland/lume/issues/418
[#419]: https://github.com/lumeland/lume/issues/419

[1.17.2]: https://github.com/lumeland/lume/compare/v1.17.1...HEAD
[1.17.1]: https://github.com/lumeland/lume/compare/v1.17.0...v1.17.1
Expand Down
27 changes: 14 additions & 13 deletions core/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type EntryType = "file" | "directory";

export interface Options {
root: string;
ignore?: (string | ((entry: Entry) => boolean))[];
ignore?: (string | ((path: string) => boolean))[];
}

export type Loader = (path: string) => Promise<Data>;
Expand Down Expand Up @@ -92,15 +92,15 @@ export default class FS {
return entry;
}

#isValid(entry: Entry) {
#isValid(path: string) {
const { ignore } = this.options;

return ignore
? !ignore.some((ignore) =>
typeof ignore === "string"
? (entry.path.startsWith(posix.join(ignore, "/")) ||
entry.path === ignore)
: ignore(entry)
? (path.startsWith(posix.join(ignore, "/")) ||
path === ignore)
: ignore(path)
)
: true;
}
Expand All @@ -114,17 +114,18 @@ export default class FS {
}

const path = posix.join(dir.path, dirEntry.name);

if (!this.#isValid(path)) {
continue;
}

const entry = new Entry(
dirEntry.name,
path,
dirEntry.isDirectory ? "directory" : "file",
posix.join(this.options.root, path),
);

if (!this.#isValid(entry)) {
continue;
}

dir.children.set(dirEntry.name, entry);
this.entries.set(path, entry);

Expand Down Expand Up @@ -159,17 +160,17 @@ export default class FS {
const prefix = parent.path === "/" ? "" : parent.path;
const path = `${prefix}/${name}`;

if (!this.#isValid(path)) {
break;
}

parent = children.get(name) || new Entry(
name,
path,
"directory",
this.options.root + path,
);

if (!this.#isValid(parent)) {
break;
}

children.set(name, parent);
this.entries.set(parent.path, parent);
}
Expand Down
9 changes: 2 additions & 7 deletions core/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,7 @@ export default class Site {
const { quiet, includes, cwd, prettyUrls, components } = this.options;

// To load source files
const fs = new FS({
root: src,
ignore: [
posix.join("/", this.options.dest),
(entry) => entry.name.startsWith("."),
],
});
const fs = new FS({ root: src });
const formats = new Formats();

const dataLoader = new DataLoader({ formats });
Expand Down Expand Up @@ -208,6 +202,7 @@ export default class Site {

// Ignore the dest folder by the watcher
this.options.watcher.ignore.push(this.options.dest);
this.fs.options.ignore = this.options.watcher.ignore;
}

get globalData(): Data {
Expand Down

0 comments on commit 2621c5d

Please sign in to comment.