Flat contract prefix definition from input

This commit is contained in:
viktor 2017-08-21 13:32:21 +03:00
parent da9216d772
commit 2acae1c8bd
2 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@ let inputFileDir = path.dirname(inputFilePath);
let parentDir = inputFileDir;
//Output directory to store flat combined solidity file
let outDir = args.length > 1?args[1]:config?config.outputDir:"./out";
let flatContractPrefix = args.length > 2?args[2]:path.basename(inputFilePath, ".sol");
let allSrcFiles = [];
let importedSrcFiles = {};
@ -27,5 +28,6 @@ module.exports = {
parentDir: parentDir,
outDir: outDir,
allSrcFiles: allSrcFiles,
importedSrcFiles: importedSrcFiles
importedSrcFiles: importedSrcFiles,
flatContractPrefix: flatContractPrefix
}

View File

@ -27,7 +27,7 @@ function getAllSolFilesCallBack(inputFileContent, dir, path, srcFiles) {
replaceAllImportsRecursively(intermediateFileContent, dir, function(outputFileContent) {
outputFileContent = removeDoubledSolidityVersion(outputFileContent);
if (!fs.existsSync(variables.outDir)) fs.mkdirSync(variables.outDir);
fs.writeFileSync(variables.outDir + "/" + pathLib.basename(variables.inputFilePath, ".sol") + "_flat.sol", outputFileContent);
fs.writeFileSync(variables.outDir + "/" + variables.flatContractPrefix + "_flat.sol", outputFileContent);
console.log("Success! Flat file is generated to " + variables.outDir + " directory");
});
});