FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Generate script: write temp generated files to OS specific temp dir · nodegit/nodegit@71b3ff2 · GitHub

Repository navigation

Commit 71b3ff2

Browse files
Kyle Smith
committed
Generate script: write temp generated files to OS specific temp dir
1 parent 7f448f5 commit 71b3ff2

5 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/lib/nodegit.js
77
/node_modules/
88
/src/
9-
/temp/
109
/test/coverage/
1110
/test/home/
1211
/test/repos/

‎generate/scripts/generateJson.js‎

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

233233

234-
utils.writeFile("output/idefs.json", output);
235-
234+
utils.writeFile(path.join(__dirname, "..", "output", "idefs.json"), output);
236235
};
237236

238237
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("output/missing-tests.json", output);
61+
utils.writeFile(path.join(__dirname, "..", "/output/missing-tests.json"), output);
6262
},
6363
function(fail) {
6464
console.error(fail);

‎generate/scripts/generateNativeCode.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require("path");
22
const promisify = require("promisify-node");
33
const fse = promisify(require("fs-extra"));
4+
const os = require('os');
45
const exec = require('../../utils/execPromise');
56
const utils = require("./utils");
67

@@ -99,7 +100,7 @@ module.exports = function generateNativeCode() {
99100
return !idef.ignore;
100101
});
101102

102-
const tempDirPath = path.resolve(__dirname, "../../temp");
103+
const tempDirPath = path.join(os.tmpdir(), 'nodegit_build');
103104
const tempSrcDirPath = path.join(tempDirPath, "src");
104105
const tempIncludeDirPath = path.join(tempDirPath, "include");
105106

@@ -113,18 +114,19 @@ module.exports = function generateNativeCode() {
113114
}).then(function() {
114115
// Write out single purpose templates.
115116
utils.writeFile("../binding.gyp", beautify(templates.binding.render(enabled)), "binding.gyp");
116-
utils.writeFile("../temp/src/nodegit.cc", templates.nodegitCC.render(enabled), "nodegit.cc");
117+
utils.writeFile(path.join(tempSrcDirPath, "nodegit.cc"), templates.nodegitCC.render(enabled), "nodegit.cc");
117118
utils.writeFile("../lib/nodegit.js", beautify(templates.nodegitJS.render(enabled)), "nodegit.js");
118119
// Write out all the classes.
119120
enabled.forEach(function(idef) {
120121
if (idef.type && idef.type != "enum") {
121122
utils.writeFile(
122-
"../temp/src/" + idef.filename + ".cc",
123+
path.format({dir: tempSrcDirPath, name: idef.filename, ext: ".cc"}),
123124
templates[idef.type + "_content"].render(idef),
124125
idef.type + "_content.cc"
125126
);
127+
126128
utils.writeFile(
127-
"../temp/include/" + idef.filename + ".h",
129+
path.format({dir: tempIncludeDirPath, name: idef.filename, ext: ".h"}),
128130
templates[idef.type + "_header"].render(idef),
129131
idef.type + "_header.h"
130132
);

‎generate/scripts/utils.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ var util = {
2929
}
3030
},
3131

32-
writeFile: function(file, content, header) {
32+
writeFile: function(filePath, content, header) {
3333
try {
34-
var file = local(file);
3534
if (typeof content == "object") {
3635
content = JSON.stringify(content, null, 2)
3736
}
@@ -45,8 +44,8 @@ var util = {
4544
content;
4645
}
4746

48-
fse.ensureFileSync(file);
49-
fse.writeFileSync(file, content);
47+
fse.ensureFileSync(filePath);
48+
fse.writeFileSync(filePath, content);
5049
return true;
5150
}
5251
catch (exception) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL