Skip to content

Commit df22691

Browse files
committed
change file creation with using File.types
1 parent 5925124 commit df22691

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

lib/core/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ Config.prototype.loadExternalContractsFiles = function() {
191191
if (contract.file.startsWith('http') || contract.file.startsWith('git')) {
192192
const url = this.getExternalContractUrl(contract);
193193
const localFile = httpContractDir + path.basename(url);
194-
this.contractsFiles.push(new File({filename: localFile, type: "http", basedir: '', path: url}));
194+
this.contractsFiles.push(new File({filename: localFile, type: File.types.http, basedir: '', path: url}));
195195
} else if (fs.existsSync(contract.file)) {
196-
this.contractsFiles.push(new File({filename: contract.file, type: "dapp_file", basedir: '', path: contract.file}));
196+
this.contractsFiles.push(new File({filename: contract.file, type: File.types.dapp_file, basedir: '', path: contract.file}));
197197
} else if (fs.existsSync(path.join('./node_modules/', contract.file))) {
198-
this.contractsFiles.push(new File({filename: path.join('./node_modules/', contract.file), type: "dapp_file", basedir: '', path: path.join('./node_modules/', contract.file)}));
198+
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)}));
199199
} else {
200200
this.logger.error("contract file not found: " + contract.file);
201201
}
@@ -302,7 +302,7 @@ Config.prototype.loadFiles = function(files) {
302302
return (file[0] === '$' || file.indexOf('.') >= 0);
303303
}).filter(function(file) {
304304
let basedir = findMatchingExpression(file, files);
305-
readFiles.push(new File({filename: file, type: "dapp_file", basedir: basedir, path: file}));
305+
readFiles.push(new File({filename: file, type: File.types.dapp_file, basedir: basedir, path: file}));
306306
});
307307

308308
var filesFromPlugins = [];
@@ -335,7 +335,7 @@ Config.prototype.loadPluginContractFiles = function() {
335335
contractsPlugins.forEach(function(plugin) {
336336
plugin.contractsFiles.forEach(function(file) {
337337
var filename = file.replace('./','');
338-
self.contractsFiles.push(new File({filename: filename, type: 'custom', resolver: function(callback) {
338+
self.contractsFiles.push(new File({filename: filename, type: File.types.custom, resolver: function(callback) {
339339
callback(plugin.loadPluginFile(file));
340340
}}));
341341
});

test/compiler.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/contracts.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ let Logger = require('../lib/core/logger.js');
44
let File = require('../lib/core/file.js');
55
let TestLogger = require('../lib/tests/test_logger.js');
66
let assert = require('assert');
7-
let fs = require('fs');
87

98
//let SolidityCompiler = require('../lib/modules/solidity');
109
let Plugins = require('../lib/core/plugins.js');
1110

1211
let readFile = function(file) {
13-
return new File({filename: file, type: 'dapp_file', path: file});
12+
return new File({filename: file, type: File.types.dapp_file, path: file});
1413
};
1514

1615
describe('embark.Contracts', function() {

test_apps/test_app/config/contracts.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
100
6464
]
6565
},
66-
"ERC20": {
67-
"file": "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"
68-
},
6966
"SimpleStorageTest": {
7067
"file": "./some_folder/test_contract.sol",
7168
"args": [

0 commit comments

Comments
 (0)