MCPcopy
hub / github.com/marktext/marktext / createProjectRoot

Function createProjectRoot

packages/desktop/src/renderer/src/store/project.ts:23–42  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

21}
22
23const createProjectRoot = (pathname: string): ProjectTree | null => {
24 const normalizedPathname = normalizeProjectRoot(pathname)
25 if (!normalizedPathname) return null
26
27 let name = window.path.basename(normalizedPathname)
28 if (!name) {
29 // Root directory such as "/" or "C:\"
30 name = normalizedPathname
31 }
32
33 return {
34 pathname: normalizedPathname,
35 name,
36 isDirectory: true,
37 isFile: false,
38 isMarkdown: false,
39 folders: [],
40 files: []
41 }
42}
43
44interface BufferedProjectState {
45 rootDirectory: string

Callers 1

OPEN_PROJECTFunction · 0.85

Calls 2

normalizeProjectRootFunction · 0.85
basenameMethod · 0.80

Tested by

no test coverage detected