We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0fccd6f commit 7cf4c2eCopy full SHA for 7cf4c2e
.gitignore
@@ -1,7 +1,13 @@
1
+# Node.js stuff
2
node_modules
-wiki
3
+package-lock.json
4
+
5
+# Editors
6
*~
7
*sublime-*
-coverage
8
/.idea
-package-lock.json
9
10
+# Development environment
11
+/coverage
12
+/benchmarks/node_envs
13
+/generation/source-data
generation/source-data/.gitignore
generation/utils.js
@@ -7,14 +7,18 @@ var request = require('request'),
// Common utilities used in scripts.
exports.getFile = function(url, cb) {
- var fullpath = path.join(__dirname, "source-data", path.basename(url));
+ var sourceDataFolder = path.join(__dirname, "source-data");
+ var fullpath = path.join(sourceDataFolder, path.basename(url));
fs.readFile(fullpath, "utf8", function(err, text) {
if (!err) return cb(null, text);
14
if (err.code != "ENOENT") return cb(err);
- request(url, errTo(cb, function(res, text) {
15
- fs.writeFile(fullpath, text, errTo(cb, function() {
16
- cb(null, text);
17
- }));
+ request(url, errTo(cb, function(res, buf) {
+ fs.mkdir(sourceDataFolder, function(err) {
+ if (err && err.code != "EEXIST") return cb(err);
18
+ fs.writeFile(fullpath, buf, errTo(cb, function() {
19
+ cb(null, buf.toString());
20
+ }));
21
+ });
22
}));
23
});
24
}
0 commit comments