Skip to content

Commit 23f8dc3

Browse files
authored
Handle action.yml with empty inputs or outputs (#138)
1 parent a82031c commit 23f8dc3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

bin/actions-gen-readme.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ async function run() {
2525
const actionContents = await readFile('action.yml', 'utf8');
2626
const action = YAML.parse(actionContents);
2727

28+
const actionInputs = Object.entries(action.inputs || {});
29+
if (actionInputs.length === 0) console.warn(`action.yml inputs are empty`);
2830
const inputs = [];
29-
for (const [input, opts] of Object.entries(action.inputs)) {
31+
for (const [input, opts] of Object.entries(actionInputs)) {
3032
const required = opts.required ? 'Required' : 'Optional';
3133
const description = opts.description
3234
.split('\n')
@@ -42,8 +44,10 @@ async function run() {
4244
const endInputs = readmeContents.indexOf('<!-- END_AUTOGEN_INPUTS -->');
4345
readmeContents.splice(startInputs + 1, endInputs - startInputs - 1, '', ...inputs, '');
4446

47+
const actionOutputs = Object.entries(action.outputs || {});
48+
if (actionOutputs.length === 0) console.warn(`action.yml outputs are empty`);
4549
const outputs = [];
46-
for (const [output, opts] of Object.entries(action.outputs)) {
50+
for (const [output, opts] of Object.entries(actionOutputs)) {
4751
const description = opts.description
4852
.split('\n')
4953
.map((line) => (line.trim() === '' ? '' : ` ${line}`))

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import js from '@eslint/js';
22
import ts from 'typescript-eslint';
33
import tsParser from '@typescript-eslint/parser';
44

5+
import globals from 'globals';
6+
57
import prettierRecommended from 'eslint-plugin-prettier/recommended';
68

79
export default ts.config(
@@ -18,4 +20,12 @@ export default ts.config(
1820
},
1921
{ ignores: ['dist/', '**/*.js'] },
2022
prettierRecommended,
23+
{
24+
files: ['**/*.mjs'],
25+
languageOptions: {
26+
globals: {
27+
...globals.node,
28+
},
29+
},
30+
},
2131
);

0 commit comments

Comments
 (0)