|
|
@ -37,11 +37,21 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) { |
|
|
|
// TODO: for now assumes filepath dir contains all tests, later all this
|
|
|
|
// TODO: for now assumes filepath dir contains all tests, later all this
|
|
|
|
// should be replaced with remix's & browser solidity compiler code
|
|
|
|
// should be replaced with remix's & browser solidity compiler code
|
|
|
|
|
|
|
|
|
|
|
|
// This logic is wrong
|
|
|
|
// https://github.com/mikeal/node-utils/blob/master/file/lib/main.js
|
|
|
|
// We should only look into current file if a full file name with path is given
|
|
|
|
fs.walkSync = function (start, callback) { |
|
|
|
// We should only walk through directory if a directory name is passed
|
|
|
|
fs.readdirSync(start).forEach(name => { |
|
|
|
try { |
|
|
|
if (name === 'node_modules') { |
|
|
|
// walkSync only if it is a directory
|
|
|
|
return; // hack
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var abspath = path.join(start, name); |
|
|
|
|
|
|
|
if (fs.statSync(abspath).isDirectory()) { |
|
|
|
|
|
|
|
fs.walkSync(abspath, callback); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
callback(abspath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
fs.walkSync(filepath, foundpath => { |
|
|
|
fs.walkSync(filepath, foundpath => { |
|
|
|
// only process .sol files
|
|
|
|
// only process .sol files
|
|
|
|
if (foundpath.split('.').pop() === 'sol') { |
|
|
|
if (foundpath.split('.').pop() === 'sol') { |
|
|
@ -53,9 +63,7 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) { |
|
|
|
sources[foundpath] = { content: c } |
|
|
|
sources[foundpath] = { content: c } |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
throw e |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
async.waterfall([ |
|
|
|
async.waterfall([ |
|
|
|
function loadCompiler (next) { |
|
|
|
function loadCompiler (next) { |
|
|
|
compiler = new RemixCompiler() |
|
|
|
compiler = new RemixCompiler() |
|
|
@ -68,7 +76,7 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) { |
|
|
|
compiler.event.register('compilationFinished', this, function (success, data, source) { |
|
|
|
compiler.event.register('compilationFinished', this, function (success, data, source) { |
|
|
|
next(null, data) |
|
|
|
next(null, data) |
|
|
|
}) |
|
|
|
}) |
|
|
|
compiler.compile(sources, filepath) |
|
|
|
compiler.compile(sources, false) |
|
|
|
} |
|
|
|
} |
|
|
|
], function (err, result) { |
|
|
|
], function (err, result) { |
|
|
|
let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error') |
|
|
|
let errors = (result.errors || []).filter((e) => e.type === 'Error' || e.severity === 'error') |
|
|
@ -79,7 +87,6 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) { |
|
|
|
cb(err, result.contracts) |
|
|
|
cb(err, result.contracts) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function compileContractSources (sources, importFileCb, opts, cb) { |
|
|
|
function compileContractSources (sources, importFileCb, opts, cb) { |
|
|
|
let compiler, filepath |
|
|
|
let compiler, filepath |
|
|
|