Comparing version 3.1.3 to 3.2.0
56
index.js
@@ -14,6 +14,6 @@ // this entire module is depressing. i should have spent my time learning | ||
var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME || ''; | ||
var exclusions = ['--help']; | ||
var exclusions = ['--help', '--completion_bash']; | ||
// This number must be incremented whenever the generated cache file changes. | ||
var CACHE_VERSION = 1; | ||
var CACHE_VERSION = 2; | ||
@@ -83,16 +83,40 @@ var configfile = '.v8flags-' + CACHE_VERSION + '-' + process.versions.v8 + '.' + crypto.createHash('md5').update(user).digest('hex') + '.json'; | ||
function getFlags(cb) { | ||
execFile(process.execPath, ['--v8-options'], function(execErr, result) { | ||
if (execErr) { | ||
return cb(execErr); | ||
} | ||
// If the binary doesn't return flags in the way we expect, default to an empty array | ||
// Reference https://github.com/gulpjs/v8flags/issues/53 | ||
var matchedFlags = result.match(/\s\s--[\w-]+/gm) || []; | ||
var flags = matchedFlags | ||
.map(normalizeFlagName) | ||
.filter(function(name) { | ||
return exclusions.indexOf(name) === -1; | ||
}); | ||
return cb(null, flags); | ||
}); | ||
var errored = false; | ||
var pending = 0; | ||
var flags = []; | ||
runNode('--help'); | ||
runNode('--v8-options'); | ||
function runNode(option) { | ||
pending++; | ||
execFile(process.execPath, [option], function(execErr, result) { | ||
if (execErr || errored) { | ||
if (!errored) { | ||
errored = true; | ||
cb(execErr); | ||
} | ||
return; | ||
} | ||
var index = result.indexOf('\nOptions:'); | ||
if (index >= 0) { | ||
var regexp = /^\s\s--[\w-]+/gm; | ||
regexp.lastIndex = index; | ||
var matchedFlags = result.match(regexp); | ||
if (matchedFlags) { | ||
flags = flags.concat(matchedFlags | ||
.map(normalizeFlagName) | ||
.filter(function(name) { | ||
return exclusions.indexOf(name) === -1; | ||
}) | ||
); | ||
} | ||
} | ||
if (--pending === 0) { | ||
cb(null, flags); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -99,0 +123,0 @@ |
{ | ||
"name": "v8flags", | ||
"version": "3.1.3", | ||
"description": "Get available v8 flags.", | ||
"version": "3.2.0", | ||
"description": "Get available v8 and Node.js flags.", | ||
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -11,3 +11,3 @@ <p align="center"> | ||
Get available v8 flags. | ||
Get available v8 and Node.js flags. | ||
@@ -14,0 +14,0 @@ ## Usage |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10925
199