warn if metadata not found

pull/2982/head
yann300 2 years ago
parent 867fbbcde8
commit 7db0067d4d
  1. 26
      libs/remixd/src/services/foundryClient.ts

@ -120,15 +120,25 @@ export class FoundryClient extends PluginClient {
// extract source and version // extract source and version
const metadata = contentJSON.metadata const metadata = contentJSON.metadata
compilationResultPart.solcVersion = metadata.compiler.version if (metadata.compiler && metadata.compiler.version) {
for (const path in metadata.sources) { compilationResultPart.solcVersion = metadata.compiler.version
const absPath = utils.absolutePath(path, this.currentSharedFolder) } else {
try { compilationResultPart.solcVersion = ''
const content = await fs.readFile(absPath, { encoding: 'utf-8' }) console.log('\x1b[32m%s\x1b[0m', 'compiler version not found, please update Foundry to the latest version.')
compilationResultPart.input[path] = { content } }
} catch (e) {
compilationResultPart.input[path] = { content: '' } if (metadata.sources) {
for (const path in metadata.sources) {
const absPath = utils.absolutePath(path, this.currentSharedFolder)
try {
const content = await fs.readFile(absPath, { encoding: 'utf-8' })
compilationResultPart.input[path] = { content }
} catch (e) {
compilationResultPart.input[path] = { content: '' }
}
} }
} else {
console.log('\x1b[32m%s\x1b[0m', 'sources input not found, please update Foundry to the latest version.')
} }

Loading…
Cancel
Save