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

Method resolveSource

tools/mcpack.js:1240–1259  ·  view source on GitHub ↗
(sourceIn)

Source from the content-addressed store, hash-verified

1238 return value;
1239 }
1240 resolveSource(sourceIn) {
1241 try {
1242 var source = ("string" == typeof sourceIn) ? sourceIn : sourceIn.source;
1243 var result = this.resolveVariable(source);
1244 var slash = result.lastIndexOf(this.slash);
1245 if (slash < 0)
1246 throw new Error("'" + source + "': path not found!");
1247 var directory = this.resolveDirectoryPath(result.slice(0, slash));
1248 if (!directory)
1249 throw new Error("'" + source + "': directory not found!");
1250 result = directory + result.slice(slash);
1251 if ("string" == typeof sourceIn)
1252 return result;
1253 return {...sourceIn, source: result};
1254 }
1255 catch(e) {
1256 this.reportError(this.currentPath, 1, e.message);
1257 }
1258 return null;
1259 }
1260 resolveVariable(value) {
1261 value = value.replace(/\$\(([^\)]+)\)/g, (offset, value) => {
1262 if (value in this.environment)

Callers 1

concatPropertiesMethod · 0.45

Calls 2

sliceMethod · 0.65
resolveVariableMethod · 0.45

Tested by

no test coverage detected