Skip to content

Commit 9a35b44

Browse files
authored
fix: confusing local specs message (#356)
Signed-off-by: Chapman Pendery <[email protected]>
1 parent 33d37a5 commit 9a35b44

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/runtime/runtime.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,19 @@ const lazyLoadSpecLocation = async (location: Fig.SpecLocation): Promise<Fig.Spe
6969
};
7070

7171
export const loadLocalSpecsSet = async () => {
72-
const specsPath = getConfig()?.specs?.path;
73-
if (!specsPath) {
74-
return;
75-
}
76-
try {
77-
await Promise.allSettled(
78-
specsPath.map((specPath) =>
79-
import(path.join(specPath, "index.js"))
80-
.then((res) => {
81-
const { default: speclist, diffVersionedCompletions: versionedSpeclist } = res;
82-
loadSpecsSet(speclist, versionedSpeclist, specPath);
83-
})
84-
.catch((e) => {
85-
log.debug({ msg: "load local spec failed", e: (e as Error).message, specPath });
86-
}),
87-
),
88-
);
89-
} catch (e) {
90-
log.debug({ msg: "load local specs failed", e: (e as Error).message, specsPath });
91-
}
72+
const specsPath = getConfig().specs.path;
73+
await Promise.allSettled(
74+
specsPath.map((specPath) =>
75+
import(path.join(specPath, "index.js"))
76+
.then((res) => {
77+
const { default: speclist, diffVersionedCompletions: versionedSpeclist } = res;
78+
loadSpecsSet(speclist, versionedSpeclist, specPath);
79+
})
80+
.catch((e) => {
81+
log.debug({ msg: `no local specs imported from '${specPath}', this will not break the current session`, e: (e as Error).message, specPath });
82+
}),
83+
),
84+
);
9285
};
9386

9487
export const getSuggestions = async (cmd: string, cwd: string, shell: Shell): Promise<SuggestionBlob | undefined> => {

src/utils/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ type Config = {
2525
dismissSuggestions: Binding;
2626
acceptSuggestion: Binding;
2727
};
28-
specs?: {
29-
path?: string[];
28+
specs: {
29+
path: string[];
3030
};
3131
useNerdFont: boolean;
3232
};
@@ -93,6 +93,9 @@ let globalConfig: Config = {
9393
acceptSuggestion: { key: "tab" },
9494
dismissSuggestions: { key: "escape" },
9595
},
96+
specs: {
97+
path: [],
98+
},
9699
useNerdFont: false,
97100
};
98101

0 commit comments

Comments
 (0)