mirror of
https://github.com/enso-org/enso.git
synced 2024-12-21 01:21:46 +03:00
Hide dotfiles on Windows (#10376)
related #10071 Request from @jdunkerley to hide all dotfiles on Windows.
This commit is contained in:
parent
2f7adb9deb
commit
dc7aa94348
@ -221,13 +221,7 @@ export default function projectManagerShimMiddleware(
|
||||
const entries: FileSystemEntry[] = []
|
||||
for (const entryName of entryNames) {
|
||||
const entryPath = path.join(directoryPath, entryName)
|
||||
try {
|
||||
if (isHiddenFile.isHiddenFile(entryPath)) continue
|
||||
} catch {
|
||||
// Ignore errors from this library, it occasionally
|
||||
// fails on windows due to native library loading
|
||||
// issues.
|
||||
}
|
||||
if (isHidden(entryPath)) continue
|
||||
const stat = await fs.stat(entryPath)
|
||||
const attributes: Attributes = {
|
||||
byteSize: stat.size,
|
||||
@ -470,3 +464,21 @@ function extractProjectMetadata(yamlObj: unknown, jsonObj: unknown): ProjectMeta
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided path should be hidden.
|
||||
*
|
||||
* On Windows, files that start with the dot but don't have the hidden property
|
||||
* should also be hidden.
|
||||
*/
|
||||
function isHidden(filePath: string): boolean {
|
||||
const dotfile = /(^|\/)\.[^/.]/g
|
||||
try {
|
||||
return isHiddenFile.isHiddenFile(filePath) || dotfile.test(filePath)
|
||||
} catch {
|
||||
// is-hidden-file library occasionally
|
||||
// fails on Windows due to native library loading
|
||||
// issues. Fallback to the filename check.
|
||||
return dotfile.test(filePath)
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,17 @@ object FileSystemListCommand {
|
||||
private def filterNotHidden(
|
||||
entries: Seq[FileSystemEntry]
|
||||
): Seq[FileSystemEntry] =
|
||||
entries.filterNot(_.path.isHidden)
|
||||
entries.filterNot(isHidden)
|
||||
|
||||
/** Checks whether the provided entry is hidden.
|
||||
*
|
||||
* On Windows, files that start with the dot but don't have the hidden
|
||||
* property should also be hidden.
|
||||
*
|
||||
* @param entry the file system entry
|
||||
* @return `true` if the entry is hidden
|
||||
*/
|
||||
private def isHidden(entry: FileSystemEntry): Boolean = {
|
||||
entry.path.isHidden || entry.path.getName.startsWith(".")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user