FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/.github/workflows/UpdateDirectory.js at master · Kesavan-77/JavaScript · GitHub
Kesavan-77
/
JavaScript
Public
forked from
TheAlgorithms/JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
.github
/
workflows
/
UpdateDirectory.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (57 loc) · 1.75 KB
Breadcrumbs
JavaScript
/
.github
/
workflows
/
UpdateDirectory.js
Copy path
File metadata and controls
71 lines (57 loc) · 1.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import
path
from
'path'
import
fs
from
'fs'
import
{
globby
}
from
'globby'
function
pathPrefix
(
i
)
{
const
res
=
' '
.
repeat
(
i
)
return
res
+
'*'
}
function
printPath
(
oldPath
,
newPath
,
output
)
{
const
oldParts
=
oldPath
.
split
(
path
.
sep
)
const
newParts
=
newPath
.
split
(
path
.
sep
)
for
(
let
i
=
0
;
i
<
newParts
.
length
;
++
i
)
{
const
newPart
=
newParts
[
i
]
if
(
i
+
1
>
oldParts
.
length
||
oldParts
[
i
]
!==
newPart
)
{
if
(
newPart
)
{
output
.
push
(
`
${
pathPrefix
(
i
)
}
**
${
newPart
.
replace
(
'_'
,
' '
)
}
**`
)
}
}
}
return
newPath
}
function
pathsToMarkdown
(
filePaths
)
{
const
output
=
[
]
let
oldPath
=
''
filePaths
.
sort
(
function
(
a
,
b
)
{
if
(
a
.
toLowerCase
(
)
<
b
.
toLowerCase
(
)
)
return
-
1
if
(
a
.
toLowerCase
(
)
>
b
.
toLowerCase
(
)
)
return
1
return
0
}
)
for
(
let
filepath
of
filePaths
)
{
let
filename
=
path
.
basename
(
filepath
)
filepath
=
path
.
dirname
(
filepath
)
if
(
filepath
!==
oldPath
)
{
oldPath
=
printPath
(
oldPath
,
filepath
,
output
)
}
let
indent
=
filepath
.
split
(
path
.
sep
)
.
length
// prepare the markdown-esque prefix to the file's line
const
prefix
=
pathPrefix
(
indent
)
// remove extension from filename
const
name
=
path
.
basename
(
filename
,
".js"
)
const
url
=
path
.
join
(
filepath
,
filename
)
output
.
push
(
`
${
prefix
}
[
${
name
}
](
${
url
}
)`
)
}
return
output
.
join
(
'\n'
)
}
// get paths of all .js files - excluding node_modules, the .github folder, tests and config stuff
globby
(
[
'**/*.js'
,
'!(node_modules|.github)/**/*'
,
"!**/test/**/*"
,
'!**/*.test.js'
,
'!**/*.manual-test.js'
,
'!vitest.config.ts'
]
)
// create markdown content
.
then
(
pathsToMarkdown
)
// write markdown to file
.
then
(
markdown
=>
fs
.
writeFileSync
(
'DIRECTORY.md'
,
markdown
+
'\n'
,
{
encoding
:
'utf8'
}
)
)
Back
|
FazBrowse Home
|
New Git URL