MCPcopy Index your code
hub / github.com/deployd/deployd / addInternalResources

Function addInternalResources

lib/config-loader.js:140–186  ·  view source on GitHub ↗
(getTypes, basepath, server, resources, fn)

Source from the content-addressed store, hash-verified

138}
139
140function addInternalResources(getTypes, basepath, server, resources, fn) {
141 new Promise(function (resolve) {
142 var defaultFolder = './public';
143 if (server.options) {
144 defaultFolder = server.options.public_dir || defaultFolder;
145 var altPublic = defaultFolder + '-' + server.options.env;
146
147 fs.exists(altPublic, function (exists) {
148 if (exists) {
149 resolve(altPublic);
150 } else {
151 resolve(defaultFolder);
152 }
153 });
154 } else {
155 resolve(defaultFolder);
156 }
157 }).then(function (publicFolder) {
158 var internals = [
159 new Files('', { config: { 'public': publicFolder }, server: server }),
160 new InternalResources('__resources', { config: { configPath: basepath }, server: server })
161 ];
162
163 return internals;
164 }).then(function (internals) {
165 return new Promise(function (resolve) {
166 getTypes(function (err, types) {
167 for (var type in types) {
168 if (types[type] && typeof types[type].selfHost === 'function') {
169 var res = types[type].selfHost({ config: { resources: resources }, server: server });
170 if (res) {
171 internals.push(res);
172 debug('Resource ' + type + ' is self hosting at /' + res.name);
173 }
174 }
175 }
176
177 resolve(internals);
178 });
179 });
180 }).then(function (internals) {
181 async.forEach(internals, loadResourceExtras, function (err) {
182 fn(err, resources.concat(internals));
183 });
184 });
185
186}

Callers

nothing calls this directly

Calls 3

resolveFunction · 0.85
debugFunction · 0.85
fnFunction · 0.85

Tested by

no test coverage detected