MCPcopy Create free account
hub / github.com/totaljs/framework / listing

Function listing

index.js:4208–4246  ·  view source on GitHub ↗
(directory, level, output, extension, isTheme)

Source from the content-addressed store, hash-verified

4206 targetdirectory = '~' + targetdirectory;
4207
4208 function listing(directory, level, output, extension, isTheme) {
4209
4210 if (!existsSync(dir))
4211 return;
4212
4213 if (!extension)
4214 extension = '.js';
4215
4216 Fs.readdirSync(directory).forEach(function(o) {
4217 var isDirectory = Fs.statSync(Path.join(directory, o)).isDirectory();
4218
4219 if (isDirectory && isTheme) {
4220 output.push({ name: o });
4221 return;
4222 }
4223
4224 if (isDirectory) {
4225
4226 if (extension === '.package' && o.endsWith(extension)) {
4227 var name = o.substring(0, o.length - extension.length);
4228 output.push({ name: name[0] === '/' ? name.substring(1) : name, filename: Path.join(dir, o), is: true });
4229 return;
4230 }
4231
4232 level++;
4233 listing(Path.join(directory, o), level, output, extension);
4234 return;
4235 }
4236
4237 var ext = U.getExtension(o);
4238 if (ext)
4239 ext = '.' + ext;
4240 if (ext !== extension || o[0] === '.' || o.endsWith('-bk' + extension) || o.endsWith('_bk' + extension))
4241 return;
4242
4243 var name = (level ? U.$normalize(directory).replace(dir, '') + '/' : '') + o.substring(0, o.length - ext.length);
4244 output.push({ name: name[0] === '/' ? name.substring(1) : name, filename: Path.join(dir, name) + extension });
4245 });
4246 }
4247
4248 try {
4249 // Reads name of resources

Callers 1

index.jsFile · 0.70

Calls 1

existsSyncFunction · 0.70

Tested by

no test coverage detected