Skip to content

Commit 80cd2f8

Browse files
committed
fix: homebrew filter improvements, filter out other text
1 parent fc6a49e commit 80cd2f8

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/resources/homebrew/casks-parameter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export class CasksParameter extends StatefulParameter<HomebrewConfig, string[]>
3333
if (caskQuery.status === SpawnStatus.SUCCESS && caskQuery.data !== null && caskQuery.data !== undefined) {
3434
const installedCasks = caskQuery.data
3535
.split('\n')
36+
.map((line) => line.trim())
3637
.filter(Boolean)
38+
// Some taps emit Ruby deprecation warnings to stderr, which the PTY interleaves
39+
// into this output. Real cask names never contain whitespace.
40+
.filter((line) => !line.includes(' '))
3741

3842
const notInstalledCasks = desired?.filter((c) => !installedCasks.includes(c));
3943
if (!notInstalledCasks || notInstalledCasks.length === 0) {

src/resources/homebrew/formulae-parameter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export class FormulaeParameter extends StatefulParameter<HomebrewConfig, string[
3131
if (formulaeQuery.status === SpawnStatus.SUCCESS && formulaeQuery.data !== null && formulaeQuery.data !== undefined) {
3232
return formulaeQuery.data
3333
.split('\n')
34-
.filter(Boolean);
34+
.map((line) => line.trim())
35+
.filter(Boolean)
36+
// Some taps emit Ruby deprecation warnings (e.g. `depends_on :macos`) to stderr,
37+
// which the PTY interleaves into this output. Real formula names never contain
38+
// whitespace, so any line with a space is noise, not a formula.
39+
.filter((line) => !line.includes(' '));
3540
}
3641

3742
return null;

src/resources/homebrew/tap-parameter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ export class TapsParameter extends StatefulParameter<HomebrewConfig, string[]> {
1717
if (tapsQuery.status === SpawnStatus.SUCCESS && tapsQuery.data !== null && tapsQuery.data !== undefined) {
1818
return tapsQuery.data
1919
.split('\n')
20+
.map((line) => line.trim())
2021
.filter((t) => t !== 'homebrew/bundle' && t !== 'homebrew/services')
2122
.filter(Boolean)
23+
// Some taps emit Ruby deprecation warnings to stderr, which the PTY interleaves
24+
// into this output. Real tap names are always `owner/repo`, with no whitespace.
25+
.filter((t) => !t.includes(' '))
2226
}
2327

2428
return null;

0 commit comments

Comments
 (0)