Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
superwunc committed Jun 17, 2024
1 parent cd90e6e commit 778d644
Showing 3 changed files with 75 additions and 12 deletions.
41 changes: 36 additions & 5 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

44 changes: 38 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
import * as core from '@actions/core'
import { wait } from './wait'

import fs from 'node:fs'

// Recursive function to get files
function getFiles(dir: string, files: string[] = []) {

Check failure on line 6 in src/main.ts

GitHub Actions / Lint Codebase

Missing return type on function

Check failure on line 6 in src/main.ts

GitHub Actions / TypeScript Tests

Missing return type on function
// Get an array of all files and directories in the passed directory using fs.readdirSync
const fileList = fs.readdirSync(dir)
// Create the full path of the file/directory by concatenating the passed directory and file/directory name
for (const file of fileList) {
const name = `${dir}/${file}`
// Check if the current file/directory is a directory using fs.statSync
if (fs.statSync(name).isDirectory()) {
// If it is a directory, recursively call the getFiles function with the directory path and the files array
getFiles(name, files)
} else {
// If it is a file, push the full path to the files array
files.push(name)
}
}
return files
}
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
console.log('core')
const www = fs.existsSync('dist')
console.log('dist', www)
const www2 = fs.existsSync('src')
console.log('src', www2)
const files = getFiles('src')

for (let i = 0, l = files.length; i < l; i++) {
const content: string = fs.readFileSync(files[i], 'utf8')
const regex = /(0x[0-9a-zA-Z]{40})/gm
let m
const contractAddress = []
while ((m = regex.exec(content)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++
}
contractAddress.push(m[0])
}
if (contractAddress.length > 0) {
console.log(files[i], contractAddress.length)
}
}
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)

0 comments on commit 778d644

Please sign in to comment.