-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.js
42 lines (31 loc) · 1.29 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* global process, __dirname */
/* eslint-disable no-console */
var gatherer, fileContent;
var createFormatter = require("vrep").create;
var format = createFormatter("'{{$", "}}'", function (value) {
return value;
});
var fs = require("fs");
var path = require("path");
var gathererDependencies = require("multiversum/utils/gatherer-context");
var createHost = require("multiversum/host").create;
var createGatherer = require("./src/gatherer.com").create;
var package = JSON.parse("" + fs.readFileSync(path.join(__dirname, "package.json")));
var runtimeTemplate = "" + fs.readFileSync(path.join(__dirname, "misc/templates/runtime.js"));
var resourcesTemplate = "" + fs.readFileSync(path.join(__dirname, "misc/templates/resources.js"));
var componentTemplate = "" + fs.readFileSync(path.join(__dirname, "misc/templates/component.js"));
var template = runtimeTemplate + resourcesTemplate;
var host = createHost();
var version = package.version;
host.connect("getModule", function (name) {
return require(name);
});
gatherer = createGatherer(host);
gatherer.init();
fileContent = host.channel("toothrotGatherer/renderTemplate")(fs, template, componentTemplate, {
paths: [process.cwd()],
prepareHost: gathererDependencies.inject
});
console.log(format(fileContent, {
version: version
}));