Skip to content

Commit

Permalink
Fix searchFileByLine
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Jan 4, 2024
1 parent 598d332 commit a0ffbd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/cli/components/status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const Status: React.FC<StatusProps> = (props) => {
? props.results.some((result) => result.result === 'error')
: props.results.result === 'error';
const results = Array.isArray(props.results) ? props.results : [props.results];
console.log(results, hasError);
return (
<Box flexDirection="column">
{hasError ? <Text color="red">Error!</Text> : <Text color="green">Success!</Text>}
Expand Down
6 changes: 3 additions & 3 deletions src/server/helpers/file-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export const replaceInFileByLine = async (filePath: string, search: string | Reg
if (replace == null) {
if (search instanceof RegExp ? line.match(search) : line.includes(search)) {
continue;
} else {
writeStream.write(line + EOL);
}
writeStream.write(line + EOL);
continue;
}
writeStream.write(line.replace(search, replace) + EOL);
}
rl.close();
await new Promise((resolve, reject) => {
writeStream.close((err) => {
if (err) {
Expand Down Expand Up @@ -59,10 +59,10 @@ export const searchFileByLine = async (filePath: string, search: string | RegExp
let result: number | false = false;
let lineNumber = 0;
for await (const line of rl) {
if (result) continue;
lineNumber++;
if (search instanceof RegExp ? line.match(search) : line.includes(search)) {
result = lineNumber;
break;
}
}
await new Promise((resolve, reject) => {
Expand Down

0 comments on commit a0ffbd5

Please sign in to comment.