Skip to content

Commit

Permalink
Check if property has value
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Thurner committed May 13, 2024
1 parent 94ff84c commit 178a29f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import * as ts from 'typescript';
// Get the file names from the command line arguments
const fileNames = process.argv.slice(2);

fileNames.forEach(fileName => {
const testFileNames = ["src/main/webapp/app/course/tutorial-groups/services/tutorial-group-free-period.service.ts"];

testFileNames.forEach(fileName => {
// Load the TypeScript file
const sourceFile = ts.createSourceFile(fileName, require('fs').readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, true);

Expand All @@ -18,7 +20,11 @@ fileNames.forEach(fileName => {
// Check if the property name is one of the httpClient methods
if (['get', 'post', 'put', 'delete'].includes(name)) {
console.log(`Found REST call: ${name}`);
console.log(`with URL: ${node.arguments[0].getText()}`);
if (node.arguments.length > 0) {
console.log(`with URL: ${node.arguments[0].getText()}`);
} else {
console.log('No arguments provided for this REST call');
}
console.log(`At line: ${sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1}`);
console.log(`At file path: ${fileName}`);
console.log('-----------------------------------');
Expand Down

0 comments on commit 178a29f

Please sign in to comment.