first implementation of resolve with custom handler

pull/5370/head
0mkar 6 years ago
parent 097a840d8e
commit 2fe116309d
  1. 2
      remix-resolve/src/index.ts
  2. 7
      remix-resolve/src/resolve.ts
  3. 141
      remix-resolve/tests/test.js

@ -4,5 +4,3 @@ const fileContent = rr.resolve('https://github.com/ethereum/greeter.sol')
const input = rr.combineSource({ 'greeter.sol': content }) const input = rr.combineSource({ 'greeter.sol': content })
*/ */
export * from './resolve' export * from './resolve'
export * from './combineSource.js'
export * from './getFile'

@ -63,15 +63,10 @@ export class ImportResolver {
type: 'ipfs', type: 'ipfs',
match: (url) => { return /^(ipfs:\/\/?.+)/.exec(url) }, match: (url) => { return /^(ipfs:\/\/?.+)/.exec(url) },
handle: (match) => { this.handleIPFS(match[1]) } handle: (match) => { this.handleIPFS(match[1]) }
},
{
type: 'local',
match: (url) => { return /(^(?!(?:http:\/\/)|(?:https:\/\/)?(?:www.)?(?:github.com)))(^\/*[\w+-_/]*\/)*?(\w+\.sol)/g.exec(url) },
handle: (match) => { this.handleLocal(match[2], match[3]) }
} }
] ]
} }
resolve(filePath: string, customHandlers: Handler[]) { async resolve(filePath: string, customHandlers: Handler[]) {
var imported: Imported = this.previouslyHandled[filePath] var imported: Imported = this.previouslyHandled[filePath]
if(imported) { if(imported) {
return imported return imported

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save