UNPKG

818 BJavaScriptView Raw
1const fs = require('fs');
2const path = require('path');
3
4const exec = require('child_process').exec;
5const version = process.versions.v8;
6const tmpfile = path.join(__dirname, version+'.flags.json');
7
8if (!fs.existsSync(tmpfile)) {
9 exec('node --v8-options', function (execErr, result) {
10 var flags;
11 if (execErr) {
12 throw new Error(execErr);
13 } else {
14 flags = result.match(/\s\s--(\w+)/gm).map(function (match) {
15 return match.substring(2);
16 });
17 fs.writeFile(tmpfile, JSON.stringify(flags), { encoding:'utf8' },
18 function (writeErr) {
19 if (writeErr) {
20 throw new Error(writeErr);
21 } else {
22 console.log('flags for v8 '+version+' cached.');
23 }
24 }
25 );
26 }
27 });
28}
29
30module.exports = require.bind(null, tmpfile);