@@ -92,21 +92,22 @@ export function getNormalizedErrMsg(errMsg: string): string {
9292}
9393
9494/**
95- * Parses the contract source code and extracts the dendencies
95+ * Parses the contract source code and extracts the dependencies
9696 * @param source Contract source code
97- * @return List of dependendencies
97+ * @return List of dependencies
9898 */
9999export function parseDependencies ( contractSource : ContractSource ) : string [ ] {
100100 // TODO: Use a proper parser
101101 const source = contractSource . source ;
102102 const sourceWithoutComments = stripComments ( source ) ;
103103 const IMPORT_REGEX = / ( i m p o r t \s ) / ;
104- const DEPENDENCY_PATH_REGEX = / " ( [ ^ " ] + ) " / ; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
105104 const dependencies : string [ ] = [ ] ;
106105 const lines = sourceWithoutComments . split ( '\n' ) ;
107106 _ . forEach ( lines , line => {
108107 if ( line . match ( IMPORT_REGEX ) !== null ) {
109- const dependencyMatch = line . match ( DEPENDENCY_PATH_REGEX ) ;
108+ const dependencyMatch =
109+ line . match ( constants . DEPENDENCY_PATH_REGEX_DOUBLE_QUOTES ) ??
110+ line . match ( constants . DEPENDENCY_PATH_REGEX_SINGLE_QUOTES ) ;
110111 if ( dependencyMatch !== null ) {
111112 let dependencyPath = dependencyMatch [ 1 ] ;
112113 if ( dependencyPath . startsWith ( '.' ) ) {
@@ -350,7 +351,9 @@ function recursivelyGatherDependencySources(
350351 const lastPathSeparatorPos = contractPath . lastIndexOf ( '/' ) ;
351352 const contractFolder = lastPathSeparatorPos === - 1 ? '' : contractPath . slice ( 0 , lastPathSeparatorPos + 1 ) ;
352353 for ( const importStatementMatch of importStatementMatches ) {
353- const importPathMatches = importStatementMatch . match ( / \" ( [ ^ \" ] * ) \" / ) ;
354+ const importPathMatches =
355+ importStatementMatch . match ( constants . DEPENDENCY_PATH_REGEX_DOUBLE_QUOTES ) ??
356+ importStatementMatch . match ( constants . DEPENDENCY_PATH_REGEX_SINGLE_QUOTES ) ;
354357 if ( importPathMatches === null || importPathMatches . length === 0 ) {
355358 continue ;
356359 }
0 commit comments