forked from gulpjs/v8flags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.js
30 lines (27 loc) · 837 Bytes
/
fetch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
const path = require('path');
const version = process.versions.v8;
const tmpfile = path.join(__dirname, version+'.flags.json');
const flagsFile = path.join(__dirname, 'flags.temp');
if (!fs.existsSync(tmpfile)) {
fs.readFile( flagsFile, function( execErr, result) {
var flags;
if (execErr) {
throw new Error(execErr);
} else {
flags = result.toString().match(/\s\s--(\w+)/gm).map(function (match) {
return match.substring(2);
});
fs.writeFile(tmpfile, JSON.stringify(flags), { encoding:'utf8' },
function (writeErr) {
if (writeErr) {
throw new Error(writeErr);
} else {
console.log('flags for v8 '+version+' cached.');
}
}
);
}
});
}
module.exports = require.bind(null, tmpfile);