-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio-slides.js
74 lines (61 loc) · 2.26 KB
/
io-slides.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var fs = require('fs')
, util = require('util')
, ncp = require('ncp').ncp
, exec = require('child_process').exec
//, prompt = require("prompt")
/* CONSTANTS */
, CONFIG_FILENAME = ".config.json";
var IoSlides = (function() {
var type = 'io-slides';
function init() {
fs.readdir(process.cwd(), function (err, files) {
if (err) { throw err; }
if (files.length > 0) {
console.log("[ERROR] directory is not empty.");
return;
}
// copy files from templates/io-slides
var sourceDir = util.format('%s/templates/io-slides', __dirname);
ncp(sourceDir, process.cwd(), function (err) {
if (err) { throw err; }
});
// create content.md file
var contentFilename = util.format("%s/content.md", process.cwd());
var defaultContent = "title: Slide Title\n" +
"subtitle: Subtitle\n\n" +
"your text here\n\n---\n\n";
fs.writeFile(contentFilename, defaultContent, function (err) {
if (err) { throw err; }
});
// config file
var config = {
"type": type,
"chapters": false
};
var config_filename = util.format("%s/%s", process.cwd(), CONFIG_FILENAME);
fs.writeFile(config_filename, JSON.stringify(config, undefined, ' '), function(err) {
if (err) { throw err; }
console.log("[ INFO] done.");
});
});
}
function view() {
var cmd = util.format("python %s/render-io-slides.py", __dirname);
exec(cmd, {cwd: process.cwd()}, function (err, stdout /* , stderr */) {
if (err) { throw err; }
console.log(stdout);
// sh("firefox presentation-output.html");
console.log("[ INFO] done.");
});
}
function cleanup() {
console.log('[ INFO] Nothing to care about.');
}
/* public functions */
return {
init: init,
view: view,
cleanup: cleanup
};
})();
module.exports = IoSlides;