From c03094a3d3bcab35163f73351dafaaa24fcef375 Mon Sep 17 00:00:00 2001 From: Dror Matalon Date: Sat, 8 Apr 2023 22:02:17 -0700 Subject: [PATCH] Add support to ignore comment lines that start with # --- src/importFiles.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/importFiles.ts b/src/importFiles.ts index 6afd25f..508a289 100644 --- a/src/importFiles.ts +++ b/src/importFiles.ts @@ -5,7 +5,8 @@ import { Utils } from "./utils.js"; /** * Handle #import statements. * Give a string, look for "#import" or "#diff" statements. - * #import file: actls like #import or #include file, by replacing the statement with the contents of a file + * #import file: acts like #import or #include file, by replacing the statement with the contents of a file + * '#' in the beginning of a line is a comment * #diff does the same but also provides a hint that the result of the request, will need to go into this file */ export function importFiles(content: string): [boolean, string, string[]] { @@ -48,7 +49,12 @@ export function importFiles(content: string): [boolean, string, string[]] { return [false, `#import file ${filePath} was not found`, toDiffFiles]; } } else { - // If the line is not an #import or #diff statement, add it to the modified lines list as is + // Check if the line is a comment + if (line.trim().startsWith("#")) { + // If it is, ignore the line and continue with the next line + continue; + } + // If the line is not an #import or #diff or a comment, add it to the modified lines list as is modifiedLines.push(line); } }