MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / _fileSystemInfo

Function _fileSystemInfo

lib/models/addon.js:975–1017  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

973 },
974
975 _fileSystemInfo() {
976 if (this._cachedFileSystemInfo) {
977 return this._cachedFileSystemInfo;
978 }
979
980 let jsExtensions = this.registry.extensionsForType('js');
981 let templateExtensions = this.registry.extensionsForType('template');
982 let addonTreePath = this._treePathFor('addon');
983 let addonTemplatesTreePath = this._treePathFor('addon-templates');
984 let addonTemplatesTreeInAddonTree = addonTemplatesTreePath.indexOf(addonTreePath) === 0;
985
986 let files = this._getAddonTreeFiles();
987
988 let addonTemplatesRelativeToAddonPath =
989 addonTemplatesTreeInAddonTree && addonTemplatesTreePath.replace(`${addonTreePath}/`, '');
990 let podTemplateMatcher = new RegExp(`template.(${templateExtensions.join('|')})$`);
991 let hasPodTemplates = files.some((file) => {
992 // short circuit if this is actually an `addon/templates` file
993 if (addonTemplatesTreeInAddonTree && file.indexOf(addonTemplatesRelativeToAddonPath) === 0) {
994 return false;
995 }
996
997 return podTemplateMatcher.test(file);
998 });
999
1000 let jsMatcher = new RegExp(`(${jsExtensions.join('|')})$`);
1001 let hasJSFiles = files.some((file) => jsMatcher.test(file));
1002
1003 if (!addonTemplatesTreeInAddonTree) {
1004 files = files.concat(this._getAddonTemplatesTreeFiles());
1005 }
1006
1007 let extensionMatcher = new RegExp(`(${templateExtensions.join('|')})$`);
1008 let hasTemplates = files.some((file) => extensionMatcher.test(file));
1009
1010 this._cachedFileSystemInfo = {
1011 hasJSFiles,
1012 hasTemplates,
1013 hasPodTemplates,
1014 };
1015
1016 return this._cachedFileSystemInfo;
1017 },
1018
1019 _getAddonTreeFiles() {
1020 let addonTreePath = this._treePathFor('addon');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…