forked from ming-codes/ember-cli-d3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathember-cli-build.js
64 lines (53 loc) · 2 KB
/
ember-cli-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
54
55
56
57
58
59
60
61
62
63
64
/* jshint node: true */
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
var plugins = require('d3-plugins-dist');
var writer = require('broccoli-caching-writer');
var md = require('commonmark');
var fs = require('fs');
var path = require('path');
var Parser = md.Parser;
var HtmlRenderer = md.HtmlRenderer;
var DocWriter = function DocWriter(inputNodes, options) {
options = options || {};
writer.call(this, inputNodes, {
annotation: options.annotation
});
this.parser = new Parser();
this.renderer = new HtmlRenderer();
};
DocWriter.prototype = Object.create(writer.prototype);
DocWriter.prototype.constructor = DocWriter;
DocWriter.prototype.build = function() {
// Read 'foo.txt' from the third input node
var inputBuffer = fs.readFileSync(path.join(this.inputPaths[0], 'guides/guides.md'), 'utf8');
var outputBuffer = this.parser.parse(inputBuffer);
// Write to 'bar.txt' in this node's output
fs.writeFileSync(path.join(this.outputPath, 'guides.html'), this.renderer.render(outputBuffer));
};
/*
This Brocfile specifes the options for the dummy test app of this
addon, located in `/tests/dummy`
This Brocfile does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's Brocfile
*/
module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
d3: {
plugins: plugins.reduce(function (accum, plugin) {
accum[plugin.author] = accum[plugin.author] || [];
accum[plugin.author].push(plugin.name);
return accum;
}, {})
},
sassOptions: {
extension: 'scss'
}
});
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/github-markdown-css/github-markdown.css');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
app.import('bower_components/faker/build/build/faker.js');
app.import('bower_components/lodash/lodash.js');
return app.toTree(new DocWriter([ 'docs' ]));
};