Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47a68d2

Browse filesBrowse files
committed
prettify generated output
1 parent fb52c7e commit 47a68d2
Copy full SHA for 47a68d2

File tree

Expand file treeCollapse file tree

3 files changed

+41
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+41
-2
lines changed
Open diff view settings
Collapse file

‎.astylerc‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--style=linux
2+
--indent=spaces=2
3+
--attach-namespaces
4+
--attach-classes
5+
--attach-inlines
6+
--attach-extern-c
Collapse file

‎generate/index.js‎

Copy file name to clipboardExpand all lines: generate/index.js
+34-2Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ const file = require("./util/file");
44
const idefs = require("./idefs");
55
const promisify = require("promisify-node");
66
const fse = promisify(require("fs-extra"));
7+
const js_beautify = require('js-beautify').js_beautify;
8+
const beautify = function (input) {
9+
return js_beautify(input, {
10+
"brace_style": "end-expand",
11+
"max_preserve_newlines": 2,
12+
"preserve_newlines": true,
13+
"indent_size": 2,
14+
"indent_char": " "
15+
});
16+
}
17+
18+
19+
var exec = promisify(function(command, opts, callback) {
20+
return require("child_process").exec(command, opts, callback);
21+
});
722

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

89104

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

109-
file.write("../lib/enums.js", templates.enums.render(enabled));
124+
125+
file.write("../lib/enums.js", beautify(templates.enums.render(enabled)));
126+
}).then(function() {
127+
return exec('command -v astyle').then(function(astyle) {
128+
if (astyle) {
129+
return exec(
130+
'astyle --options=\".astylerc\" '
131+
+ path.resolve(__dirname, "../src") + "/*.cc "
132+
+ path.resolve(__dirname, "../include") + "/*.h"
133+
).then(function() {
134+
return exec(
135+
'rm '
136+
+ path.resolve(__dirname, "../src") + "/*.cc.orig "
137+
+ path.resolve(__dirname, "../include") + "/*.h.orig "
138+
);
139+
});
140+
}
141+
})
110142
});
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"fs-extra": "^0.12.0",
6565
"lodash": "^2.4.1",
6666
"istanbul": "~0.3.2",
67+
"js-beautify": "^1.5.4",
6768
"jshint": "~2.5.6",
6869
"mocha": "~1.21.4",
6970
"nan": "~1.3.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.