mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Feat: ability to handle inline comment
This commit is contained in:
@@ -45,9 +45,11 @@ export function fetchRemoteTextByLine(url: string, processLine = false): Promise
|
||||
|
||||
export async function readFileIntoProcessedArray(file: string /* | FileHandle */) {
|
||||
const results = [];
|
||||
let processed: string | null = '';
|
||||
for await (const line of readFileByLine(file)) {
|
||||
if (processLine(line)) {
|
||||
results.push(line);
|
||||
processed = processLine(line);
|
||||
if (processed) {
|
||||
results.push(processed);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
||||
@@ -37,6 +37,12 @@ export function processLine(line: string): string | null {
|
||||
*/
|
||||
}
|
||||
|
||||
const otherPoundSign = trimmed.indexOf('#');
|
||||
|
||||
if (otherPoundSign > 0) {
|
||||
return trimmed.slice(0, otherPoundSign).trimEnd();
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ export default async function runAgainstSourceFile(
|
||||
/** Secret keyword collection, only use for special purpose */
|
||||
keywordSet?: Set<string> | null
|
||||
) {
|
||||
let l: string | null = '';
|
||||
for await (const line of readFileByLine(filePath)) {
|
||||
const l = processLine(line);
|
||||
l = processLine(line);
|
||||
if (!l) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user