Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Clean up truffle-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
daniyarchambylov committed Mar 4, 2019
1 parent 8076482 commit 9162e93
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions compat/truffle-compile/index.js
Expand Up @@ -28,11 +28,16 @@ function findImports(pathName) {
}
}

function sourcePath2BuildPath(sourcePath, buildDir) {
const getSourceFileName = sourcePath => {
let shortName = path.basename(sourcePath);
if (shortName.endsWith('.sol')) {
shortName = shortName.slice(0, -4)
}
return shortName;
}

function sourcePath2BuildPath(sourcePath, buildDir) {
const shortName = getSourceFileName(sourcePath);
return path.join(buildDir, shortName + '.json')
}

Expand Down Expand Up @@ -247,10 +252,7 @@ var compile = function(sourcePath, sourceText, options, callback) {

// FIXME: the below return path is hoaky, because it is in the format that
// the multiPromisify'd caller in workflow-compile expects.
let shortName = path.basename(sourcePath);
if (shortName.endsWith('.sol')) {
shortName = shortName.slice(0, -4)
}
const shortName = getSourceFileName(sourcePath);

callback(null, sourcePath, {[shortName]: normalizedOutput});
})
Expand Down Expand Up @@ -417,15 +419,8 @@ compile.with_dependencies = function(options, callback) {
// Pick up from existing JSON
const buildJson = fs.readFileSync(targetJsonPath, 'utf8');
const buildObj = JSON.parse(buildJson);
console.log("FIXME: danyiar");
const normalizedOutput = normalizeJsonOutput(buildObj)

// FIXME: DRY with a subroutine - this code appears 3 times.
let shortName = path.basename(sourcePath);
if (shortName.endsWith('.sol')) {
shortName = shortName.slice(0, -4)
}
callback(null, sourcePath, {[shortName]: normalizedOutput});
const shortName = getSourceFileName(sourcePath);
callback(null, sourcePath, {[shortName]: buildObj});
}
}
var hasTargets = filteredRequired.length;
Expand Down

0 comments on commit 9162e93

Please sign in to comment.