mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-28 07:04:10 +00:00
add support for additional context roots in opencollection (#6995)
* add support for additional context roots in opencollection
This commit is contained in:
@@ -204,6 +204,9 @@ export interface BrunoConfig {
|
||||
passphrase?: string;
|
||||
}>;
|
||||
};
|
||||
scripts?: {
|
||||
additionalContextRoots?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface BrunoCollectionRoot {
|
||||
|
||||
@@ -38,6 +38,20 @@ const parseCollection = (ymlString: string): ParsedCollection => {
|
||||
}
|
||||
}
|
||||
|
||||
// bruno-specific script extensions
|
||||
const brunoExtensions = oc.extensions?.bruno as any;
|
||||
if (Array.isArray(brunoExtensions?.scripts?.additionalContextRoots)) {
|
||||
const sanitizedRoots = brunoExtensions.scripts.additionalContextRoots
|
||||
.filter((item: any) => typeof item === 'string');
|
||||
|
||||
if (sanitizedRoots.length > 0) {
|
||||
brunoConfig.scripts = {
|
||||
...brunoConfig.scripts,
|
||||
additionalContextRoots: sanitizedRoots
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// protobuf
|
||||
if (oc.config?.protobuf) {
|
||||
brunoConfig.protobuf = {
|
||||
|
||||
@@ -220,6 +220,16 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
|
||||
} as any;
|
||||
}
|
||||
|
||||
// bruno-specific script extensions
|
||||
if (brunoConfig.scripts?.additionalContextRoots?.length) {
|
||||
if (!oc.extensions.bruno) {
|
||||
oc.extensions.bruno = {};
|
||||
}
|
||||
(oc.extensions.bruno as any).scripts = {
|
||||
additionalContextRoots: brunoConfig.scripts.additionalContextRoots
|
||||
};
|
||||
}
|
||||
|
||||
return stringifyYml(oc);
|
||||
} catch (error) {
|
||||
console.error('Error stringifying opencollection.yml:', error);
|
||||
|
||||
Reference in New Issue
Block a user