MCPcopy Create free account
hub / github.com/SAP/ui5-project / getReader

Method getReader

lib/specifications/ComponentProject.js:126–166  ·  view source on GitHub ↗

* Get a [ReaderCollection]@ui5/fs/ReaderCollection for accessing all resources of the * project in the specified "style": * * * buildtime: Resource paths are always prefixed with /resources/ * or /test-resources/ followed by the project's

({style = "buildtime"} = {})

Source from the content-addressed store, hash-verified

124 * @returns {@ui5/fs/ReaderCollection} A reader collection instance
125 */
126 getReader({style = "buildtime"} = {}) {
127 // TODO: Additional style 'ABAP' using "sap.platform.abap".uri from manifest.json?
128
129 // Apply builder excludes to all styles but "runtime"
130 const excludes = style === "runtime" ? [] : this.getBuilderResourcesExcludes();
131
132 if ((style === "runtime" || style === "dist") && this._isRuntimeNamespaced) {
133 // If the project's type requires a namespace at runtime, the
134 // dist- and runtime-style paths are identical to buildtime-style paths
135 style = "buildtime";
136 }
137 let reader = this._getReader(excludes);
138 switch (style) {
139 case "buildtime":
140 break;
141 case "runtime":
142 case "dist":
143 // Use buildtime reader and link it to /
144 // No test-resources for runtime resource access,
145 // unless runtime is namespaced
146 reader = resourceFactory.createFlatReader({
147 reader,
148 namespace: this._namespace
149 });
150 break;
151 case "flat":
152 // Use buildtime reader and link it to /
153 // No test-resources for runtime resource access,
154 // unless runtime is namespaced
155 reader = resourceFactory.createFlatReader({
156 reader,
157 namespace: this._namespace
158 });
159 break;
160 default:
161 throw new Error(`Unknown path mapping style ${style}`);
162 }
163
164 reader = this._addWriter(reader, style);
165 return reader;
166 }
167
168 /**
169 * Get a resource reader for the resources of the project

Callers

nothing calls this directly

Calls 3

_getReaderMethod · 0.95
_addWriterMethod · 0.95

Tested by

no test coverage detected