MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / includeManifest

Method includeManifest

tools/mcmanifest.js:2722–2787  ·  view source on GitHub ↗
(it)

Source from the content-addressed store, hash-verified

2720 }
2721 }
2722 includeManifest(it) {
2723 var currentDirectory = this.currentDirectory;
2724 if ("string" == typeof it) {
2725 this.includeManifestPath(this.resolveVariable(it));
2726 }
2727 else {
2728 let { git, branch, tag, manifest = "manifest.json" } = it;
2729 if (!git)
2730 throw new Error("no git!");
2731 let repo = this.resolveVariable(git);
2732 if (this.windows)
2733 repo = repo.replace(/\\/g, "/");
2734 let url = new URL(repo);
2735
2736 let directory = "repos/" + url.hostname + url.pathname;
2737 if (directory.endsWith(".git"))
2738 directory = directory.slice(0, -4);
2739 if (branch)
2740 directory += "/" + branch;
2741 if (tag)
2742 directory += "/" + tag;
2743
2744 let parts = directory.split("/");
2745 let path = this.createDirectories(this.outputPath, "tmp", this.environment.NAME);
2746 directory = path + this.slash + parts.join(this.slash);
2747
2748 if (this.buildTarget != "clean") {
2749 if (this.isDirectoryOrFile(directory) == 0) {
2750 for (let part of parts) {
2751 path += this.slash + part;
2752 this.createDirectory(path);
2753 }
2754 this.currentDirectory = path;
2755 this.report("# git clone " + repo + " to path " + path);
2756 let result;
2757 if (branch)
2758 result = this.spawn("git", "clone", "-b", branch, repo, ".");
2759 else
2760 result = this.spawn("git", "clone", repo, ".");
2761 if (result != 0)
2762 throw new Error("git failed!");
2763 if (tag) {
2764 result = this.spawn("git", "-c", "advice.detachedHead=false", "checkout", tag);
2765 if (result != 0)
2766 throw new Error("git failed!");
2767 }
2768 }
2769 }
2770// else {
2771// this.currentDirectory = directory;
2772// this.report("# git pull " + name);
2773// this.spawn("git", "pull");
2774// }
2775 if (this.isDirectoryOrFile(directory) < 0) {
2776 if (typeof manifest == "string") {
2777 this.includeManifestPath(directory + this.slash + this.resolveVariable(manifest));
2778 }
2779 else {

Callers 1

parseManifestMethod · 0.95

Calls 8

includeManifestPathMethod · 0.95
resolveVariableMethod · 0.95
parseManifestMethod · 0.95
replaceMethod · 0.80
reportMethod · 0.80
sliceMethod · 0.65
createDirectoriesMethod · 0.45
createDirectoryMethod · 0.45

Tested by

no test coverage detected