Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
prettify generated output
  • Loading branch information
maxkorp committed Nov 25, 2014
commit 47a68d222a7fd79c3a4fbc1fdee033fb282e92ef
6 changes: 6 additions & 0 deletions .astylerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--style=linux
--indent=spaces=2
--attach-namespaces
--attach-classes
--attach-inlines
--attach-extern-c
36 changes: 34 additions & 2 deletions generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ const file = require("./util/file");
const idefs = require("./idefs");
const promisify = require("promisify-node");
const fse = promisify(require("fs-extra"));
const js_beautify = require('js-beautify').js_beautify;
const beautify = function (input) {
return js_beautify(input, {
"brace_style": "end-expand",
"max_preserve_newlines": 2,
"preserve_newlines": true,
"indent_size": 2,
"indent_char": " "
});
}


var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});

// Customize the delimiters so as to not process `{{{` or `}}}`.
combyne.settings.delimiters = {
Expand Down Expand Up @@ -83,7 +98,7 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
return fse.copy(path.resolve(__dirname, "./manual/"), path.resolve(__dirname, "../"));
}).then(function() {
// Write out single purpose templates.
file.write("../binding.gyp", templates.binding.render(enabled));
file.write("../binding.gyp", beautify(templates.binding.render(enabled)));
file.write("../src/nodegit.cc", templates.nodegit.render(enabled));


Expand All @@ -106,5 +121,22 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
}
});

file.write("../lib/enums.js", templates.enums.render(enabled));

file.write("../lib/enums.js", beautify(templates.enums.render(enabled)));
}).then(function() {
return exec('command -v astyle').then(function(astyle) {
if (astyle) {
return exec(
'astyle --options=\".astylerc\" '
+ path.resolve(__dirname, "../src") + "/*.cc "
+ path.resolve(__dirname, "../include") + "/*.h"
).then(function() {
return exec(
'rm '
+ path.resolve(__dirname, "../src") + "/*.cc.orig "
+ path.resolve(__dirname, "../include") + "/*.h.orig "
);
});
}
})
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"fs-extra": "^0.12.0",
"lodash": "^2.4.1",
"istanbul": "~0.3.2",
"js-beautify": "^1.5.4",
"jshint": "~2.5.6",
"mocha": "~1.21.4",
"nan": "~1.3.0",
Expand Down