Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Rewriting the fors to find the files (#247)
Browse files Browse the repository at this point in the history
* Rewriting the fors to find the files

* fix error output in tests
  • Loading branch information
Perseverance authored and ochikov committed Jul 3, 2019
1 parent 7d9744e commit 36299b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
8 changes: 1 addition & 7 deletions packages/etherlime/cli-commands/compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@ const compilePromise = async (compileOptions, quiet) => {
resolve();
}
catch (error) {
let stack = error['stack'].split(',/');

stack.forEach(message => {
logger.log(message);
});

return reject(stack);
return reject(error);
}
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ let find_contracts = async (workingPath) => {
}

try {


const readFiles = await readAllFilesSync(workingPath);
return resolve(fetchSolAndVyperFiles(readFiles))
} catch (err) {
Expand All @@ -28,29 +30,31 @@ let find_contracts = async (workingPath) => {
});
}

const readAllFilesSync = async function(dir, fileList) {
const readAllFilesSync = async function (dir, fileList) {
files = await fs.readdirSync(dir);
fileList = fileList || [];
for(let i = 0; i < files.length; i++) {
const filePath = path.join(dir, files[i])
for (const file of files) {
const filePath = path.join(dir, file)
if (fs.statSync(filePath).isDirectory()) {
fileList = await readAllFilesSync(filePath, fileList);
fileList = await readAllFilesSync(filePath, fileList);
}
else {
fileList.push(filePath);
fileList.push(filePath);
}
}
return fileList;
};

const fetchSolAndVyperFiles = (files) => {

let solFiles = [];
let vyperFiles = [];

files.forEach(file => {
for (const file of files) {
if (path.extname(file) == SOL_EXTENSION && path.basename(file)[0] != '.') solFiles.push(file)
if (path.extname(file) == VYPER_EXTENSION && path.basename(file)[0] != '.') vyperFiles.push(file)
})
}


return { solFiles, vyperFiles }
}
Expand Down
4 changes: 2 additions & 2 deletions test/etherlime/cli-commands/commands/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('root calling cli commands', () => {
it('should throw err if compile cli command failed', async function () {
let expectedOutput = "ENOENT: no such file or directory"
let childProcess = await runCmdHandler(`etherlime compile`, expectedOutput);
assert.include(childProcess.output, expectedOutput)
assert.include(childProcess, expectedOutput)
});

it('should throw err if test cli command failed', async function () {
Expand All @@ -54,7 +54,7 @@ describe('root calling cli commands', () => {
it('should throw err if deploy failed', async function () {
let expectedOutput = "ENOENT: no such file or directory"
let childProcess = await runCmdHandler(`etherlime deploy`, expectedOutput);
assert.include(childProcess.output, expectedOutput)
assert.include(childProcess, expectedOutput)
});

it('should throw err if ganache failed', async function () {
Expand Down

0 comments on commit 36299b1

Please sign in to comment.