Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support glob path #2

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 5 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require("fs");
const { globSync } = require("glob");
const yaml = require("js-yaml");
const core = require("@actions/core");

Expand All @@ -7,18 +8,12 @@ const validUsers = (core.getInput("api_users") || process.env.API_USERS || '')
.split(",")
.filter((u) => !!u);

const files = fs.readdirSync(path).filter((f) => f.endsWith(".yaml"));

fs.readdirSync(path)
.filter((f) => f.endsWith(".yml"))
.forEach((file) => {
fail(`Error with file ${file}, replace .yml with .yaml`);
});
const files = globSync([`${path}/*.{yml,yaml}`]);

files
.map((file) => {
try {
const content = yaml.load(fs.readFileSync(`${path}/${file}`, "utf8"));
const content = yaml.load(fs.readFileSync(file, "utf8"));
return [file, content];
} catch (error) {
fail(`Error parsing file ${file} : ${error}`);
Expand Down Expand Up @@ -58,7 +53,7 @@ function parsePost(fileName, content) {
fail(`File ${fileName} with type post must have a topic and body`);
}

if (!files.includes(topic + ".yaml")) {
if (!globSync(`${path}/${topic}.{yml,yaml}`)) {
fail(
`File ${fileName} has an invalid topic, ${topic}.yaml does not exist `
);
Expand All @@ -82,7 +77,7 @@ function parsePosts(fileName, content) {
parseAPIUser(fileName, subApi);
})

if (!files.includes(topic + ".yaml")) {
if (!globSync(`${path}/${topic}.{yml,yaml}`)) {
fail(
`File ${fileName} has an invalid topic, ${topic}.yaml does not exist `
);
Expand Down
1 change: 1 addition & 0 deletions node_modules/.bin/glob

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading