Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
fef17669
Commit
fef17669
authored
Jun 27, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: skip empty JSON
parent
9ae6ee9e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
sendDiffToGoogleSheets.ts
...detect_section_selector_masters/sendDiffToGoogleSheets.ts
+11
-5
No files found.
src/detect_section_selector_masters/sendDiffToGoogleSheets.ts
View file @
fef17669
...
...
@@ -71,6 +71,13 @@ async function uploadAllToSheets() {
}
for
(
const
{
subdir
,
file
,
path
}
of
files
)
{
// Read and skip empty JSON
const
fileRaw
=
readFileSync
(
path
,
'utf-8'
);
const
fileData
=
JSON
.
parse
(
fileRaw
);
if
(
Array
.
isArray
(
fileData
)
&&
fileData
.
length
===
0
)
{
console
.
log
(
`🚫 Skipping empty file
${
file
}
`
);
continue
;
}
// Use file name (without extension) as sheetName
const
sheetName
=
file
.
replace
(
/
\.
json$/
,
''
);
if
(
!
existing
.
includes
(
sheetName
))
{
...
...
@@ -81,15 +88,14 @@ async function uploadAllToSheets() {
requests
:
[{
addSheet
:
{
properties
:
{
title
:
sheetName
}
}
}]
}
});
existing
.
push
(
sheetName
);
}
const
raw
=
readFileSync
(
path
,
'utf-8'
);
const
data
=
JSON
.
parse
(
raw
);
// Always clear existing values, even for empty data, to overwrite the sheet
await
sheets
.
spreadsheets
.
values
.
clear
({
spreadsheetId
,
range
:
`'
${
sheetName
}
'`
});
if
(
d
ata
.
length
)
{
const
headers
=
Object
.
keys
(
d
ata
[
0
]);
const
rows
=
d
ata
.
map
((
row
:
any
)
=>
if
(
fileD
ata
.
length
)
{
const
headers
=
Object
.
keys
(
fileD
ata
[
0
]);
const
rows
=
fileD
ata
.
map
((
row
:
any
)
=>
headers
.
map
((
h
:
string
)
=>
{
const
cell
=
row
[
h
];
return
cell
!=
null
&&
typeof
cell
===
'object'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment