11const  fs  =  require ( './fs.js' ) ; 
2- const  File  =  require ( './file.js' ) ; 
32const  Plugins  =  require ( './plugins.js' ) ; 
43const  utils  =  require ( '../utils/utils.js' ) ; 
54const  path  =  require ( 'path' ) ; 
@@ -11,6 +10,7 @@ const cloneDeep = require('lodash.clonedeep');
1110import  {  replaceZeroAddressShorthand  }  from  '../utils/addressUtils' ; 
1211import  {  unitRegex  }  from  "../utils/regexConstants" ; 
1312import  *  as  utilsContractsConfig  from  "../utils/contractsConfig" ; 
13+ import  {  File ,  Types  }  from  "./file" ; 
1414
1515const  DEFAULT_CONFIG_PATH  =  'config/' ; 
1616
@@ -59,13 +59,13 @@ var Config = function(options) {
5959    resolver  =  resolver  ||  function ( callback )  { 
6060      callback ( fs . readFileSync ( filename ) . toString ( ) ) ; 
6161    } ; 
62-     self . contractsFiles . push ( new  File ( { filename,  type : File . types . custom ,   path :  filename ,  resolver} ) ) ; 
62+     self . contractsFiles . push ( new  File ( { path :  filename ,  type : Types . custom ,  resolver} ) ) ; 
6363  } ) ; 
6464
6565  self . events . on ( 'file-remove' ,  ( fileType ,  removedPath )  =>  { 
6666    if ( fileType  !==  'contract' )  return ; 
6767    const  normalizedPath  =  path . normalize ( removedPath ) ; 
68-     self . contractsFiles  =  self . contractsFiles . filter ( file  =>  path . normalize ( file . filename )  !==  normalizedPath ) ; 
68+     self . contractsFiles  =  self . contractsFiles . filter ( file  =>  path . normalize ( file . path )  !==  normalizedPath ) ; 
6969  } ) ; 
7070} ; 
7171
@@ -127,7 +127,7 @@ Config.prototype.loadContractFiles = function() {
127127  if  ( ! this . contractFiles  ||  newContractsFiles . length  !==  this . contractFiles . length  ||  ! deepEqual ( newContractsFiles ,  this . contractFiles ) )  { 
128128    this . contractsFiles  =  this . contractsFiles . concat ( newContractsFiles ) . filter ( ( file ,  index ,  arr )  =>  { 
129129      return  ! arr . some ( ( file2 ,  index2 )  =>  { 
130-         return  file . filename  ===  file2 . filename  &&  index  <  index2 ; 
130+         return  file . path  ===  file2 . path  &&  index  <  index2 ; 
131131      } ) ; 
132132    } ) ; 
133133  } 
@@ -369,11 +369,11 @@ Config.prototype.loadExternalContractsFiles = function() {
369369        return  this . logger . error ( __ ( "HTTP contract file not found" )  +  ": "  +  contract . file ) ; 
370370      } 
371371      const  localFile  =  fileObj . filePath ; 
372-       this . contractsFiles . push ( new  File ( { filename : localFile ,  type : File . types . http ,  basedir : '' ,  path : fileObj . url ,  storageConfig : storageConfig } ) ) ; 
372+       this . contractsFiles . push ( new  File ( { path : localFile ,  type : Types . http ,  basedir : '' ,  externalUrl : fileObj . url ,  storageConfig : storageConfig } ) ) ; 
373373    }  else  if  ( fs . existsSync ( contract . file ) )  { 
374-       this . contractsFiles . push ( new  File ( { filename : contract . file ,  type : File . types . dapp_file ,  basedir : '' ,   path :  contract . file ,  storageConfig : storageConfig } ) ) ; 
374+       this . contractsFiles . push ( new  File ( { path : contract . file ,  type : Types . dappFile ,  basedir : '' ,  storageConfig : storageConfig } ) ) ; 
375375    }  else  if  ( fs . existsSync ( path . join ( './node_modules/' ,  contract . file ) ) )  { 
376-       this . contractsFiles . push ( new  File ( { filename : path . join ( './node_modules/' ,  contract . file ) ,  type : File . types . dapp_file ,  basedir : '' ,   path :  path . join ( './node_modules/' ,   contract . file ) ,  storageConfig : storageConfig } ) ) ; 
376+       this . contractsFiles . push ( new  File ( { path : path . join ( './node_modules/' ,  contract . file ) ,  type : Types . dappFile ,  basedir : '' ,  storageConfig : storageConfig } ) ) ; 
377377    }  else  { 
378378      this . logger . error ( __ ( "contract file not found" )  +  ": "  +  contract . file ) ; 
379379    } 
@@ -571,7 +571,7 @@ Config.prototype.loadFiles = function(files) {
571571    return  ( file [ 0 ]  ===  '$'  ||  file . indexOf ( '.' )  >=  0 ) ; 
572572  } ) . filter ( function ( file )  { 
573573    let  basedir  =  findMatchingExpression ( file ,  files ) ; 
574-     readFiles . push ( new  File ( { filename : file ,  type : File . types . dapp_file ,  basedir : basedir ,   path :  file ,  storageConfig : storageConfig } ) ) ; 
574+     readFiles . push ( new  File ( { path : file ,  type : Types . dappFile ,  basedir : basedir ,  storageConfig : storageConfig } ) ) ; 
575575  } ) ; 
576576
577577  var  filesFromPlugins  =  [ ] ; 
@@ -605,7 +605,7 @@ Config.prototype.loadPluginContractFiles = function() {
605605  contractsPlugins . forEach ( function ( plugin )  { 
606606    plugin . contractsFiles . forEach ( function ( file )  { 
607607      var  filename  =  file . replace ( './' , '' ) ; 
608-       self . contractsFiles . push ( new  File ( { filename : filename ,  pluginPath : plugin . pluginPath ,  type : File . types . custom ,   path :  filename ,  storageConfig : storageConfig ,  resolver : function ( callback )  { 
608+       self . contractsFiles . push ( new  File ( { path : filename ,  pluginPath : plugin . pluginPath ,  type : Types . custom ,  storageConfig : storageConfig ,  resolver : function ( callback )  { 
609609        callback ( plugin . loadPluginFile ( file ) ) ; 
610610      } } ) ) ; 
611611    } ) ; 
0 commit comments