FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plugins/scripts/validate.mjs at main · SPlayer-Dev/plugins · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SPlayer-Dev
/
plugins
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
4
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
plugins
/
scripts
/
validate.mjs
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (29 loc) · 1.03 KB
Breadcrumbs
plugins
/
scripts
/
validate.mjs
Copy path
File metadata and controls
34 lines (29 loc) · 1.03 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
/**
* 仓库内全量校验:PR / 本地运行
*
* 校验所有 plugins/*.js:头部合法、@id 与文件名一致、id 唯一;敏感用法仅以 warning 提示。
* 有任一错误则退出码 1。
*/
import
{
readdirSync
,
readFileSync
}
from
"node:fs"
;
import
{
validate
,
DANGER_PATTERNS
}
from
"./header.mjs"
;
const
DIR
=
"plugins"
;
let
failed
=
false
;
const
seen
=
new
Set
(
)
;
for
(
const
file
of
readdirSync
(
DIR
)
.
filter
(
(
name
)
=>
name
.
endsWith
(
".js"
)
)
)
{
const
id
=
file
.
slice
(
0
,
-
3
)
;
if
(
seen
.
has
(
id
)
)
{
console
.
error
(
`
${
file
}
: 重复 id
${
id
}
`
)
;
failed
=
true
;
}
seen
.
add
(
id
)
;
const
source
=
readFileSync
(
`
${
DIR
}
/
${
file
}
`
,
"utf-8"
)
;
for
(
const
err
of
validate
(
id
,
source
)
.
errors
)
{
console
.
error
(
`
${
file
}
:
${
err
}
`
)
;
failed
=
true
;
}
for
(
const
pattern
of
DANGER_PATTERNS
)
{
if
(
pattern
.
test
(
source
)
)
console
.
log
(
`::warning file=
${
DIR
}
/
${
file
}
::疑似敏感用法
${
pattern
}
`
)
;
}
}
console
.
log
(
`校验
${
seen
.
size
}
个插件,
${
failed
?
"未通过"
:
"全部通过"
}
`
)
;
process
.
exit
(
failed
?
1
:
0
)
;
Back
|
FazBrowse Home
|
New Git URL