Socket
Socket
Sign inDemoInstall

v8flags

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8flags - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

5

config-path.js
var os = require('os');
var path = require('path');
var userHome = require('homedir-polyfill')();
var userHome = os.homedir();

@@ -20,7 +20,6 @@ var env = process.env;

function linux() {
var username = path.basename(userHome);
return path.join(env.XDG_CACHE_HOME || path.join(userHome, '.cache'), name);
}
module.exports = function(platform) {
module.exports = function (platform) {
if (!userHome) {

@@ -27,0 +26,0 @@ return os.tmpdir();

108

index.js

@@ -11,11 +11,17 @@ // this entire module is depressing. i should have spent my time learning

var configPath = require('./config-path.js')(process.platform);
var version = require('./package.json').version;
var env = process.env;
var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME || '';
var exclusions = ['--help', '--completion_bash'];
var exclusions = ['--help', '--completion-bash'];
// This number must be incremented whenever the generated cache file changes.
var CACHE_VERSION = 2;
var CACHE_VERSION = 3;
var configfile = '.v8flags-' + CACHE_VERSION + '-' + process.versions.v8 + '.' + crypto.createHash('md5').update(user).digest('hex') + '.json';
var configfile =
'.v8flags-' +
CACHE_VERSION +
'-' +
process.versions.v8 +
'.' +
crypto.createHash('sha256').update(user).digest('hex') +
'.json';

@@ -37,4 +43,4 @@ var failureMessage = [

function openConfig(cb) {
fs.mkdir(configPath, function() {
tryOpenConfig(path.join(configPath, configfile), function(err, fd) {
fs.mkdir(configPath, function () {
tryOpenConfig(path.join(configPath, configfile), function (err, fd) {
if (err) {

@@ -54,3 +60,3 @@ return tryOpenConfig(path.join(os.tmpdir(), configfile), cb);

var content = require(configpath);
process.nextTick(function() {
process.nextTick(function () {
cb(null, content);

@@ -63,3 +69,3 @@ });

// write the cached data to
fs.open(configpath, 'w+', function(err, fd) {
fs.open(configpath, 'w+', function (err, fd) {
if (err) {

@@ -73,8 +79,4 @@ return cb(err);

// Node <= 9 outputs _ in flags with multiple words, while node 10
// uses -. Both ways are accepted anyway, so always use `_` for better
// compatibility.
// We must not replace the first two --.
function normalizeFlagName(flag) {
return '--' + flag.slice(4).replace(/-/g, '_');
return flag.trim();
}

@@ -87,40 +89,26 @@

function getFlags(cb) {
var errored = false;
var pending = 0;
var flags = [];
var flags = Array.from(process.allowedNodeEnvironmentFlags);
runNode('--help');
runNode('--v8-options');
execFile(process.execPath, ['--v8-options'], function (execErr, result) {
if (execErr) {
cb(execErr);
return;
}
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;
})
);
}
}
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);
}
});
}
cb(null, flags);
});
}

@@ -132,17 +120,5 @@

var json = JSON.stringify(flags);
var buf;
if (Buffer.from && Buffer.from !== Uint8Array.from) {
// Node.js 4.5.0 or newer
buf = Buffer.from(json);
} else {
// Old Node.js versions
// The typeof safeguard below is mostly against accidental copy-pasting
// and code rewrite, it never happens as json is always a string here.
if (typeof json === 'number') {
throw new Error('Unexpected type number');
}
buf = new Buffer(json);
}
return fs.write(fd, buf, 0, buf.length, 0 , function(writeErr) {
fs.close(fd, function(closeErr) {
var buf = Buffer.from(json);
return fs.write(fd, buf, 0, buf.length, 0, function (writeErr) {
fs.close(fd, function (closeErr) {
var err = writeErr || closeErr;

@@ -157,7 +133,7 @@ if (err) {

module.exports = function(cb) {
module.exports = function (cb) {
// bail early if this is not node
var isElectron = process.versions && process.versions.electron;
if (isElectron) {
return process.nextTick(function() {
return process.nextTick(function () {
cb(null, []);

@@ -168,3 +144,3 @@ });

// attempt to open/read cache file
openConfig(function(openErr, result) {
openConfig(function (openErr, result) {
if (!openErr && typeof result !== 'number') {

@@ -175,3 +151,3 @@ return cb(null, result);

// the flags by invoking node with `--v8-options`
getFlags(function(flagsErr, flags) {
getFlags(function (flagsErr, flags) {
// if there was an error fetching the flags, bail immediately

@@ -178,0 +154,0 @@ if (flagsErr) {

{
"name": "v8flags",
"version": "3.2.0",
"version": "4.0.0",
"description": "Get available v8 and Node.js flags.",
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)",
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
"contributors": [

@@ -16,3 +16,3 @@ "Tyler Kellen <tyler@sleekcode.net>",

"engines": {
"node": ">= 0.10"
"node": ">= 10.13.0"
},

@@ -28,19 +28,24 @@ "main": "index.js",

"pretest": "npm run lint",
"test": "mocha --async-only",
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls"
"test": "nyc mocha --async-only"
},
"dependencies": {
"homedir-polyfill": "^1.0.1"
},
"dependencies": {},
"devDependencies": {
"async": "^2.5.0",
"eslint": "^2.13.0",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"mocha": "^3.5.3",
"proxyquire": "^1.8.0"
"async": "^3.2.2",
"eslint": "^7.32.0",
"eslint-config-gulp": "^5.0.1",
"eslint-plugin-node": "^11.1.0",
"expect": "^27.3.1",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"proxyquire": "^2.1.3"
},
"nyc": {
"reporter": [
"lcov",
"text-summary"
]
},
"prettier": {
"singleQuote": true
},
"keywords": [

@@ -47,0 +52,0 @@ "v8 flags",

@@ -9,3 +9,3 @@ <p align="center">

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

@@ -15,6 +15,7 @@ Get available v8 and Node.js flags.

## Usage
```js
const v8flags = require('v8flags');
v8flags(function(err, results) {
v8flags(function (err, results) {
console.log(results);

@@ -52,16 +53,12 @@ // [ '--use_strict',

[downloads-image]: http://img.shields.io/npm/dm/v8flags.svg
<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/v8flags.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/v8flags
[npm-image]: http://img.shields.io/npm/v/v8flags.svg
[npm-image]: https://img.shields.io/npm/v/v8flags.svg?style=flat-square
[travis-url]: https://travis-ci.org/gulpjs/v8flags
[travis-image]: http://img.shields.io/travis/gulpjs/v8flags.svg?label=travis-ci
[ci-url]: https://github.com/gulpjs/v8flags/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/v8flags/dev?style=flat-square
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/v8flags
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/v8flags.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/v8flags
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/v8flags/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/v8flags/master.svg?style=flat-square
<!-- prettier-ignore-end -->

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc