From df226919c0dccb4ed61a7f688756293f0ab7a674 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 18 Apr 2018 15:02:50 -0400 Subject: [PATCH] change file creation with using File.types --- lib/core/config.js | 10 +++++----- test/compiler.js | 2 +- test/contracts.js | 3 +-- test_apps/test_app/config/contracts.json | 3 --- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 24f0ef9dd..a77185d6b 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -191,11 +191,11 @@ Config.prototype.loadExternalContractsFiles = function() { if (contract.file.startsWith('http') || contract.file.startsWith('git')) { const url = this.getExternalContractUrl(contract); const localFile = httpContractDir + path.basename(url); - this.contractsFiles.push(new File({filename: localFile, type: "http", basedir: '', path: url})); + this.contractsFiles.push(new File({filename: localFile, type: File.types.http, basedir: '', path: url})); } else if (fs.existsSync(contract.file)) { - this.contractsFiles.push(new File({filename: contract.file, type: "dapp_file", basedir: '', path: contract.file})); + this.contractsFiles.push(new File({filename: contract.file, type: File.types.dapp_file, basedir: '', path: contract.file})); } else if (fs.existsSync(path.join('./node_modules/', contract.file))) { - this.contractsFiles.push(new File({filename: path.join('./node_modules/', contract.file), type: "dapp_file", basedir: '', path: path.join('./node_modules/', contract.file)})); + 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)})); } else { this.logger.error("contract file not found: " + contract.file); } @@ -302,7 +302,7 @@ Config.prototype.loadFiles = function(files) { return (file[0] === '$' || file.indexOf('.') >= 0); }).filter(function(file) { let basedir = findMatchingExpression(file, files); - readFiles.push(new File({filename: file, type: "dapp_file", basedir: basedir, path: file})); + readFiles.push(new File({filename: file, type: File.types.dapp_file, basedir: basedir, path: file})); }); var filesFromPlugins = []; @@ -335,7 +335,7 @@ Config.prototype.loadPluginContractFiles = function() { contractsPlugins.forEach(function(plugin) { plugin.contractsFiles.forEach(function(file) { var filename = file.replace('./',''); - self.contractsFiles.push(new File({filename: filename, type: 'custom', resolver: function(callback) { + self.contractsFiles.push(new File({filename: filename, type: File.types.custom, resolver: function(callback) { callback(plugin.loadPluginFile(file)); }})); }); diff --git a/test/compiler.js b/test/compiler.js index 24377df04..bc7194631 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -5,7 +5,7 @@ let File = require('../lib/core/file.js'); let assert = require('assert'); let readFile = function(file) { - return new File({filename: file, type: 'dapp_file', path: file}); + return new File({filename: file, type: File.types.dapp_file, path: file}); }; var solcVersion = "0.4.17"; diff --git a/test/contracts.js b/test/contracts.js index 4de8db568..466ed101c 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -4,13 +4,12 @@ let Logger = require('../lib/core/logger.js'); let File = require('../lib/core/file.js'); let TestLogger = require('../lib/tests/test_logger.js'); let assert = require('assert'); -let fs = require('fs'); //let SolidityCompiler = require('../lib/modules/solidity'); let Plugins = require('../lib/core/plugins.js'); let readFile = function(file) { - return new File({filename: file, type: 'dapp_file', path: file}); + return new File({filename: file, type: File.types.dapp_file, path: file}); }; describe('embark.Contracts', function() { diff --git a/test_apps/test_app/config/contracts.json b/test_apps/test_app/config/contracts.json index 3ae09f341..f40ff865d 100644 --- a/test_apps/test_app/config/contracts.json +++ b/test_apps/test_app/config/contracts.json @@ -63,9 +63,6 @@ 100 ] }, - "ERC20": { - "file": "zeppelin-solidity/contracts/token/ERC20/ERC20.sol" - }, "SimpleStorageTest": { "file": "./some_folder/test_contract.sol", "args": [