Skip to content

Commit 3369b1a

Browse files
committed
fix processing files that have variable declaration without an initializer and fixing logs
1 parent 7334780 commit 3369b1a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pythagora",
3-
"version": "0.0.76",
3+
"version": "0.0.78",
44
"author": {
55
"name": "Zvonimir Sabljic",
66
"email": "[email protected]"

src/bin/run.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ do
6060
exit 0
6161
elif [[ "${args[$i]}" == "--unit-tests" ]]
6262
then
63-
echo "${green}${bold}Generating unit tests...${reset}"
63+
echo "${green}${bold}Starting generation of unit tests...${reset}"
6464
PYTHAGORA_CONFIG="$@" node "${pythagora_dir}/src/scripts/unit.js"
6565
exit 0
6666
elif [[ "${args[$i]}" == "--export-setup" ]]

src/helpers/unitTests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function processFile(filePath, filesToProcess) {
6666
if (importedFile && !filesToProcess.includes(importedFile)) {
6767
filesToProcess.push(importedFile);
6868
}
69-
} else if (node.type === "VariableDeclaration" && node.declarations[0].init.type === "CallExpression" && node.declarations[0].init.callee.name === "require") {
69+
} else if (node.type === "VariableDeclaration" && node.declarations.length > 0 && node.declarations[0].init && node.declarations[0].init.type === "CallExpression" && node.declarations[0].init.callee.name === "require") {
7070
let importedFile = path.resolve(path.dirname(filePath), node.declarations[0].init.arguments[0].value);
7171
importedFile = resolveFilePath(importedFile, extension);
7272
if (importedFile && !filesToProcess.includes(importedFile)) {
@@ -365,12 +365,14 @@ async function generateTestsForDirectory(args, processingFunction = 'getUnitTest
365365
API.checkForAPIKey();
366366
queriedPath = path.resolve(pathToProcess);
367367
rootPath = args.pythagora_root;
368-
({ screen, spinner, scrollableContent } = initScreenForUnitTests());
368+
console.log('Processing folder structure...');
369369

370370
await traverseDirectory(queriedPath, true, funcName, processingFunction);
371371
processedFiles = [];
372372
await traverseDirectory(queriedPath, true, funcName, processingFunction);
373373
processedFiles = [];
374+
console.log('Generating tests...');
375+
({ screen, spinner, scrollableContent } = initScreenForUnitTests());
374376
await traverseDirectory(queriedPath, false, funcName, processingFunction);
375377

376378
screen.destroy();

0 commit comments

Comments
 (0)