Skip to content

Commit

Permalink
Merge pull request #416 from jill64/dev
Browse files Browse the repository at this point in the history
Refactor listWorkflowFiles to use path.join and add error handling
  • Loading branch information
wraith-ci[bot] authored Dec 20, 2023
2 parents 0701051 + a21c5e4 commit 74ed5e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
13 changes: 8 additions & 5 deletions packages/action/dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34358,11 +34358,14 @@ var updateReadmeList = async ({
var import_promises6 = require("node:fs/promises");
var import_node_path4 = __toESM(require("node:path"), 1);
var listWorkflowFiles = async () => {
const dirPath = ".github/workflows";
const dir = await (0, import_promises6.readdir)(dirPath, {
withFileTypes: true,
recursive: true
});
const dirPath = import_node_path4.default.join(process.cwd(), ".github/workflows");
const dir = await attempt(
() => (0, import_promises6.readdir)(dirPath, {
withFileTypes: true,
recursive: true
}),
[]
);
const result = dir.filter((dirent) => dirent.isFile()).map(async (file) => {
const filepath = import_node_path4.default.join(dirPath, file.name);
const data = await (0, import_promises6.readFile)(filepath, "utf-8");
Expand Down
16 changes: 11 additions & 5 deletions packages/action/src/ghosts/docs/utils/listWorkflowFiles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { attempt } from '@jill64/attempt'
import { readdir, readFile } from 'node:fs/promises'
import path from 'node:path'

export const listWorkflowFiles = async () => {
const dirPath = '.github/workflows'
const dir = await readdir(dirPath, {
withFileTypes: true,
recursive: true
})
const dirPath = path.join(process.cwd(), '.github/workflows')

const dir = await attempt(
() =>
readdir(dirPath, {
withFileTypes: true,
recursive: true
}),
[]
)

const result = dir
.filter((dirent) => dirent.isFile())
Expand Down

0 comments on commit 74ed5e9

Please sign in to comment.