MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / filterCommonjs

Method filterCommonjs

tools/mcconfig.js:981–1009  ·  view source on GitHub ↗
(commonjs)

Source from the content-addressed store, hash-verified

979 return path;
980 }
981 filterCommonjs(commonjs) {
982 this.commonjs = false;
983 if (commonjs.length) {
984 this.commonjs = true;
985 for (var jsFile of this.jsFiles) {
986 jsFile.commonjs = false;
987 }
988 for (var pattern of commonjs) {
989 pattern = this.resolveSlash(pattern);
990 var star = pattern.lastIndexOf("*");
991 if (star >= 0) {
992 pattern = pattern.slice(0, star);
993 for (var result of this.jsFiles) {
994 var target = result.target.slice(0, star);
995 if (target == pattern)
996 result.commonjs = true;
997 }
998 }
999 else {
1000 pattern += ".xsb";
1001 for (var result of this.jsFiles) {
1002 var target = result.target;
1003 if (target == pattern)
1004 result.commonjs = true;
1005 }
1006 }
1007 }
1008 }
1009 }
1010 filterConfig(config) {
1011 this.mergeProperties(config, this.config);
1012 if (this.format) {

Callers 1

runMethod · 0.80

Calls 2

sliceMethod · 0.65
resolveSlashMethod · 0.45

Tested by

no test coverage detected