-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.js
executable file
·53 lines (45 loc) · 1.54 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
43
44
45
46
47
48
49
50
51
52
53
var fs = require('fs')
var ncp = require('ncp');
var package = JSON.parse(fs.readFileSync("package.json", "utf-8"))
var html = fs.readFileSync("src/storyFormat.html", "utf-8")
html = html.replace(/\{\{ENGINE_URL\}\}/g, 'http://localhost:3000/');
var outputJSON = {
name: package.name,
version: package.version,
author: package.author,
description: package.description,
proofing: false,
source: html
};
var outputString = "window.storyFormat(" + JSON.stringify(outputJSON, null, 2) + ");";
fs.writeFile("dist/format.js", outputString, function(err) {
if (err) {
console.log("Error building story format:", err);
} else {
console.log("Successfully built story format to dist/format.js");
}
});
ncp('Monogatari/dist', 'dist/Monogatari', function (err) {
if (err) {
return console.error("Error copying Monogatari engine", err);
}
console.log('Successfully copied engine to dist/Monogatari/');
});
ncp('src/twison.js', 'dist/twison.js', function (err) {
if (err) {
return console.error("Error copying twison.js", err);
}
console.log('Successfully copied twison.js');
});
ncp('src/twine-monogatari.js', 'dist/twine-monogatari.js', function (err) {
if (err) {
return console.error("Error copying twine-monogatari.js", err);
}
console.log('Successfully copied twine-monogatari.js');
});
ncp('src/Monogatari', 'dist/Monogatari', function (err) {
if (err) {
return console.error("Error copying Monogatari custom scripts", err);
}
console.log('Successfully copied custom scripts to dist/Monogatari/js');
});