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

DARK: Themes > Ignore user created folders inside default theme dirs #68

Merged
merged 4 commits into from
Sep 3, 2024
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
11 changes: 11 additions & 0 deletions packages/cli-kit/lib/node/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export async function exists(path: string): Promise<boolean> {
}
}

export async function isDirectory(path: string): Promise<boolean> {
try {
const stats: Stats = await FilesystemPromises.stat(path);

return stats.isDirectory();
}
catch {
return false;
}
}

export async function tapIntoTmp<T>(callback: (tmp: string) => T | Promise<T>): Promise<T> {
return temporaryDirectoryTask(callback);
}
Expand Down
9 changes: 8 additions & 1 deletion packages/theme/lib/cli/commands/theme/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ export default class Dev extends ThemeCommand {
}

for (const file of present.filter(f => !descriptors.find(d => d.file_name === f))) {
const path = Path.resolve(directory, file);
const isDir = await Filesystem.isDirectory(path);

if (isDir) {
continue;
}

await execute(theme, 'save', type, file);
}

for (const descriptor of descriptors) {
const path = Path.resolve(directory, descriptor.file_name);
if (!(await Filesystem.exists(path))) {
if ((await Filesystem.isDirectory(path)) || !(await Filesystem.exists(path))) {
return await execute(theme, 'delete', type, descriptor.file_name);
}

Expand Down
1 change: 1 addition & 0 deletions packages/theme/lib/cli/services/dev/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class ThemeWorker extends Worker.Abstract {
awaitWriteFinish: { stabilityThreshold: 50 },
ignoreInitial: true,
persistent: true,
depth: 0,
});

this.command.controller.signal.addEventListener('abort', () => {
Expand Down