1
1
const fs = require ( './fs.js' ) ;
2
- const File = require ( './file.js' ) ;
3
2
const Plugins = require ( './plugins.js' ) ;
4
3
const utils = require ( '../utils/utils.js' ) ;
5
4
const path = require ( 'path' ) ;
@@ -11,6 +10,7 @@ const cloneDeep = require('lodash.clonedeep');
11
10
import { replaceZeroAddressShorthand } from '../utils/addressUtils' ;
12
11
import { unitRegex } from "../utils/regexConstants" ;
13
12
import * as utilsContractsConfig from "../utils/contractsConfig" ;
13
+ import { File , Types } from "./file" ;
14
14
15
15
const DEFAULT_CONFIG_PATH = 'config/' ;
16
16
@@ -59,13 +59,13 @@ var Config = function(options) {
59
59
resolver = resolver || function ( callback ) {
60
60
callback ( fs . readFileSync ( filename ) . toString ( ) ) ;
61
61
} ;
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} ) ) ;
63
63
} ) ;
64
64
65
65
self . events . on ( 'file-remove' , ( fileType , removedPath ) => {
66
66
if ( fileType !== 'contract' ) return ;
67
67
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 ) ;
69
69
} ) ;
70
70
} ;
71
71
@@ -127,7 +127,7 @@ Config.prototype.loadContractFiles = function() {
127
127
if ( ! this . contractFiles || newContractsFiles . length !== this . contractFiles . length || ! deepEqual ( newContractsFiles , this . contractFiles ) ) {
128
128
this . contractsFiles = this . contractsFiles . concat ( newContractsFiles ) . filter ( ( file , index , arr ) => {
129
129
return ! arr . some ( ( file2 , index2 ) => {
130
- return file . filename === file2 . filename && index < index2 ;
130
+ return file . path === file2 . path && index < index2 ;
131
131
} ) ;
132
132
} ) ;
133
133
}
@@ -369,11 +369,11 @@ Config.prototype.loadExternalContractsFiles = function() {
369
369
return this . logger . error ( __ ( "HTTP contract file not found" ) + ": " + contract . file ) ;
370
370
}
371
371
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 } ) ) ;
373
373
} 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 } ) ) ;
375
375
} 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 } ) ) ;
377
377
} else {
378
378
this . logger . error ( __ ( "contract file not found" ) + ": " + contract . file ) ;
379
379
}
@@ -571,7 +571,7 @@ Config.prototype.loadFiles = function(files) {
571
571
return ( file [ 0 ] === '$' || file . indexOf ( '.' ) >= 0 ) ;
572
572
} ) . filter ( function ( file ) {
573
573
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 } ) ) ;
575
575
} ) ;
576
576
577
577
var filesFromPlugins = [ ] ;
@@ -605,7 +605,7 @@ Config.prototype.loadPluginContractFiles = function() {
605
605
contractsPlugins . forEach ( function ( plugin ) {
606
606
plugin . contractsFiles . forEach ( function ( file ) {
607
607
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 ) {
609
609
callback ( plugin . loadPluginFile ( file ) ) ;
610
610
} } ) ) ;
611
611
} ) ;
0 commit comments