Skip to content

Commit 272c37b

Browse files
author
Kyle Smith
committed
Generate utils: separated writeFile into writeFile and writeLocalFile
1 parent 880d2d1 commit 272c37b

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

generate/scripts/generateJson.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ module.exports = function generateJson() {
231231
}
232232

233233

234-
utils.writeFile(path.join(__dirname, "..", "output", "idefs.json"), output);
234+
utils.writeLocalFile("output/idefs.json", output);
235235
};
236236

237237
if (require.main === module) {

generate/scripts/generateMissingTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function generateMissingTests() {
5858

5959
Promise.all(promises).then(
6060
function() {
61-
utils.writeFile(path.join(__dirname, "..", "/output/missing-tests.json"), output);
61+
utils.writeLocalFile("/output/missing-tests.json", output);
6262
},
6363
function(fail) {
6464
console.error(fail);

generate/scripts/generateNativeCode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ module.exports = function generateNativeCode() {
113113
return fse.copy(path.resolve(__dirname, "../templates/manual/src"), tempSrcDirPath);
114114
}).then(function() {
115115
// Write out single purpose templates.
116-
utils.writeFile("../binding.gyp", beautify(templates.binding.render(enabled)), "binding.gyp");
116+
utils.writeLocalFile("../binding.gyp", beautify(templates.binding.render(enabled)), "binding.gyp");
117117
utils.writeFile(path.join(tempSrcDirPath, "nodegit.cc"), templates.nodegitCC.render(enabled), "nodegit.cc");
118-
utils.writeFile("../lib/nodegit.js", beautify(templates.nodegitJS.render(enabled)), "nodegit.js");
118+
utils.writeLocalFile("../lib/nodegit.js", beautify(templates.nodegitJS.render(enabled)), "nodegit.js");
119119
// Write out all the classes.
120120
enabled.forEach(function(idef) {
121121
if (idef.type && idef.type != "enum") {
@@ -133,7 +133,7 @@ module.exports = function generateNativeCode() {
133133
}
134134
});
135135

136-
utils.writeFile("../lib/enums.js", beautify(templates.enums.render(enabled)), "enums.js");
136+
utils.writeLocalFile("../lib/enums.js", beautify(templates.enums.render(enabled)), "enums.js");
137137
}).then(function() {
138138
return exec("command -v astyle").then(function(astyle) {
139139
if (astyle) {

generate/scripts/utils.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ var util = {
1111
pointerRegex: /\s*\*\s*/,
1212
doublePointerRegex: /\s*\*\*\s*/,
1313

14-
readLocalFile: function(file) {
15-
try {
16-
return fs.readFileSync(local(file)).toString();
17-
}
18-
catch (unhandledException) {
19-
return "";
20-
}
14+
readLocalFile: function(filePath) {
15+
return util.readFile(local(filePath));
2116
},
2217

2318
readFile: function(filePath) {
@@ -29,6 +24,10 @@ var util = {
2924
}
3025
},
3126

27+
writeLocalFile: function(filePath, content, header) {
28+
return util.writeFile(local(filePath), content, header);
29+
},
30+
3231
writeFile: function(filePath, content, header) {
3332
try {
3433
if (typeof content == "object") {

0 commit comments

Comments
 (0)