Skip to content

Commit 2f4df1b

Browse files
committed
wip 3
1 parent 71651ba commit 2f4df1b

File tree

1 file changed

+9
-10
lines changed
  • .github/actions/meson-format-action

1 file changed

+9
-10
lines changed

.github/actions/meson-format-action/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ async function execAndGetStdout(executable, args) {
5959
throw new Error(`${executable} exited with exit code ${exitCode}`)
6060
}
6161

62-
return output.split('\n')
62+
/** @type {string[]} */
63+
const result = output === '' ? [] : output.split('\n')
64+
65+
return result
6366
}
6467

6568
/**
@@ -76,7 +79,7 @@ async function getMesonFiles(onlyGitFiles) {
7679

7780
if (onlyGitFiles) {
7881
/** @type {string[]} */
79-
const gitFiles = mesonFiles.map((file) => `--exclude='${file}'`)
82+
const gitFiles = mesonFiles.flatMap((file) => ['--exclude', file])
8083

8184
files = await execAndGetStdout('git', [
8285
'ls-files',
@@ -124,7 +127,7 @@ async function checkFile(file, formatFile) {
124127
}
125128

126129
/** @type {string[]} */
127-
const additionalArgs = formatFile == '' ? [] : ['-c', formatFile]
130+
const additionalArgs = formatFile === '' ? [] : ['-c', formatFile]
128131

129132
/** @type {number} */
130133
const exitCode = await exec.exec(
@@ -133,7 +136,7 @@ async function checkFile(file, formatFile) {
133136
options
134137
)
135138

136-
return exitCode == 0
139+
return exitCode === 0
137140
}
138141

139142
/**
@@ -151,10 +154,6 @@ async function main() {
151154
)
152155
}
153156

154-
//WIP
155-
core.error(`file input is: ${core.getInput('format-file', { required: false })}`)
156-
core.error(`git-file input is: ${core.getInput('only-git-files', { required: false })}`)
157-
158157
/** @type {string} */
159158
const formatFile = core.getInput('format-file', { required: false })
160159

@@ -202,7 +201,7 @@ async function main() {
202201

203202
core.endGroup()
204203

205-
if (notFormattedFiles.length == 0) {
204+
if (notFormattedFiles.length === 0) {
206205
core.summary.clear()
207206

208207
core.summary.addHeading('Result', 1)
@@ -238,7 +237,7 @@ async function main() {
238237
)
239238

240239
/** @type {string} */
241-
const additionalArgs = formatFile == '' ? [] : [`-c ${formatFile}`]
240+
const additionalArgs = formatFile === '' ? [] : [`-c ${formatFile}`]
242241

243242
/** @type {string} */
244243
const finalFileList = notFormattedFiles.join(' ')

0 commit comments

Comments
 (0)