From d4251c72b3e811c416ca8308cadc14736ee89af5 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Sun, 2 Apr 2023 02:17:31 +0100 Subject: [PATCH] reduce string manipulation --- apps/doc-gen/src/app/App.tsx | 3 +-- apps/doc-gen/src/app/docgen-client.ts | 5 ++--- apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts | 2 +- apps/remix-ide/src/app/plugins/solidity-umlgen.tsx | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/doc-gen/src/app/App.tsx b/apps/doc-gen/src/app/App.tsx index bb3411f721..9c3aa01a08 100644 --- a/apps/doc-gen/src/app/App.tsx +++ b/apps/doc-gen/src/app/App.tsx @@ -18,9 +18,8 @@ const App = () => { setThemeType(theme) }) client.eventEmitter.on('compilationFinished', (build: Build, fileName: string) => { - const temp = fileName.split('/')[fileName.split('/').length - 1] setHasBuild(true) - setFileName(temp) + setFileName(fileName) }) client.eventEmitter.on('docsGenerated', (docs: string[]) => { }) diff --git a/apps/doc-gen/src/app/docgen-client.ts b/apps/doc-gen/src/app/docgen-client.ts index 1e94d8aebc..7216c94161 100644 --- a/apps/doc-gen/src/app/docgen-client.ts +++ b/apps/doc-gen/src/app/docgen-client.ts @@ -49,7 +49,7 @@ export class DocGenClient extends PluginClient { output: output } const test = normalizeContractPath(fileName, true) - this.fileName = typeof test === 'string' ? test : test[1] + this.fileName = typeof test === 'string' ? test : test[test.length - 1] this.contractPath = typeof test === 'object' ? test[0] : '' this.eventEmitter.emit('compilationFinished', this.build, this.fileName) }) @@ -63,8 +63,7 @@ export class DocGenClient extends PluginClient { const renderedSite = render(site, templates, config.collapseNewlines) const docs: string[] = [] for (const { id, contents } of renderedSite) { - const pathArray = this.fileName.split('/') - const temp = `${pathArray[pathArray.length - 1]}.${id.split('.')[1]}` + const temp = `${this.fileName}.${id.split('.')[1]}` const newFileName = `docs/${temp}` await this.call('fileManager', 'setFile', newFileName , contents) docs.push(newFileName) diff --git a/apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts b/apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts index 7f52d5e031..c177316a7f 100644 --- a/apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts +++ b/apps/doc-gen/src/app/docgen/utils/normalizeContractPath.ts @@ -10,7 +10,7 @@ export function normalizeContractPath(contractPath: string, returnPath?: boolean } const resultingPath = `${folders}${filename}` if(returnPath) { - return [folders,resultingPath] + return [folders,resultingPath, filename] } else { return resultingPath } diff --git a/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx b/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx index 79a9df4ebf..76d99c3c86 100644 --- a/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx +++ b/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx @@ -140,9 +140,7 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen { * @returns {Promise} */ async flattenContract (source: any, filePath: string, data: any) { - const appendage = '_flattened.sol' - const temp = await this.call('contractflattener', 'flattenContract', source, filePath, data) - const result = `${temp}${appendage}` + const result = await this.call('contractflattener', 'flattenContract', source, filePath, data) return result }