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

Function getPaths

src/cli.ts:17–54  ·  view source on GitHub ↗
(argv: { output: string; input: string; constantsFile: any; testContracts?: string; hardhatOutput?: string; })

Source from the content-addressed store, hash-verified

15} from './project'
16
17const getPaths = (argv: { output: string; input: string; constantsFile: any; testContracts?: string; hardhatOutput?: string; }) => {
18 const inputFiles = getInputFiles(argv);
19
20 const hardhatProjectInfo = getHardhatProjectInfo(argv);
21
22 if (argv.output) {
23 if (isSolFile(argv.output)) {
24 if (inputFiles.length > 1) {
25 throw new Error('Can not specify file output with directory input')
26 }
27 } else if (!fs.existsSync(argv.output)) {
28 fs.mkdirSync(argv.output);
29 }
30 } else {
31 if (hardhatProjectInfo?.contractsDirectory) {
32 argv.output = mkdirIfNotExists(path.join(hardhatProjectInfo.contractsDirectory, 'types'))
33 } else {
34 argv.output = process.cwd();
35 }
36 }
37 const makeConstantsFile = argv.constantsFile === undefined
38 ? argv.output && !isSolFile(argv.output)
39 : argv.constantsFile;
40
41 const constantsFilePath = makeConstantsFile && path.join(getDir(argv.output), './CoderConstants.sol');
42
43 const testContractsDirectory = argv.testContracts || hardhatProjectInfo?.testContractsDirectory
44 const hardhatTestsDirectory = argv.hardhatOutput || hardhatProjectInfo?.hardhatTestsDirectory
45
46 return {
47 inputFiles,
48 output: argv.output,
49 constantsFilePath,
50 testContractsDirectory,
51 hardhatTestsDirectory,
52 projectType: hardhatProjectInfo?.projectType,
53 }
54}
55
56yargs
57 .command(

Callers 1

cli.tsFile · 0.85

Calls 5

getInputFilesFunction · 0.90
getHardhatProjectInfoFunction · 0.90
isSolFileFunction · 0.90
mkdirIfNotExistsFunction · 0.90
getDirFunction · 0.90

Tested by

no test coverage detected