Skip to content

Commit

Permalink
feat: allow specifying only library name in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Jul 18, 2023
1 parent f229833 commit f042329
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,14 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise<vo
recursive: true,
});
} else {
const relativeFilePath = filteredQualifiedNames[i].split(':')[0];
const [relativeFilePath, contractName] = filteredQualifiedNames[i].split(':');
let { outputDir } = config;

outputDir = config.libraries.includes(relativeFilePath)
? `${config.outputDir}/libraries`
: `${config.outputDir}/contracts`;
if (config.libraries.includes(relativeFilePath) || config.libraries.includes(contractName)) {
outputDir = `${config.outputDir}/libraries`;
} else {
outputDir = `${config.outputDir}/contracts`;
}

try {
await fs.promises.access(outputDir);
Expand All @@ -606,12 +608,14 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise<vo
encoding: 'utf-8',
});
} else {
const relativeFilePath = filteredQualifiedNames[i].split(':')[0];
const [relativeFilePath, contractName] = filteredQualifiedNames[i].split(':');
let { outputDir } = config;

outputDir = config.libraries.includes(relativeFilePath)
? `${config.outputDir}/libraries`
: `${config.outputDir}/contracts`;
if (config.libraries.includes(relativeFilePath) || config.libraries.includes(contractName)) {
outputDir = `${config.outputDir}/libraries`;
} else {
outputDir = `${config.outputDir}/contracts`;
}

try {
await fs.promises.access(outputDir);
Expand All @@ -634,12 +638,14 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise<vo
},
);
} else {
const relativeFilePath = filteredQualifiedNames[i].split(':')[0];
const [relativeFilePath, contractName] = filteredQualifiedNames[i].split(':');
let { outputDir } = config;

outputDir = config.libraries.includes(relativeFilePath)
? `${config.outputDir}/libraries`
: `${config.outputDir}/contracts`;
if (config.libraries.includes(relativeFilePath) || config.libraries.includes(contractName)) {
outputDir = `${config.outputDir}/libraries`;
} else {
outputDir = `${config.outputDir}/contracts`;
}

try {
await fs.promises.access(outputDir);
Expand Down

0 comments on commit f042329

Please sign in to comment.