(argv: { output: string; input: string; constantsFile: any; testContracts?: string; hardhatOutput?: string; })
| 15 | } from './project' |
| 16 | |
| 17 | const 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 | |
| 56 | yargs |
| 57 | .command( |
no test coverage detected