MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / getInputFiles

Function getInputFiles

src/project/inputs.ts:9–34  ·  view source on GitHub ↗
(argv: { input: string })

Source from the content-addressed store, hash-verified

7export type FileWithStructs = { fileName: string; structs: Array<AbiStruct | AbiEnum> }
8
9export const getInputFiles = (argv: { input: string }): FileWithStructs[] => {
10 if (!fs.existsSync(argv.input)) {
11 throw new Error(`File or directory not found: ${argv.input}`);
12 }
13 const files: FileWithStructs[] = [];
14 const filePaths: string[] = [];
15 if (isDir(argv.input)) {
16 const fileNames = fs.readdirSync(argv.input).filter(isSolFile);
17 for (const fileName of fileNames) {
18 const filePath = path.join(argv.input, fileName);
19 filePaths.push(filePath);
20 }
21 } else {
22 if (!isSolFile(argv.input)) {
23 throw new Error(`${argv.input} is not a Solidity file`)
24 }
25 filePaths.push(argv.input);
26 }
27 for (const filePath of filePaths) {
28 const { name } = path.parse(filePath);
29 const code = fs.readFileSync(filePath, 'utf8');
30 const structs = parseCode(code) as Array<AbiStruct | AbiEnum>;
31 files.push({ fileName: name, structs })
32 }
33 return files;
34}

Callers 1

getPathsFunction · 0.90

Calls 3

isDirFunction · 0.90
isSolFileFunction · 0.90
parseCodeFunction · 0.90

Tested by

no test coverage detected