@babel/node
Advanced tools
Comparing version 7.0.0-beta.42 to 7.0.0-beta.43
"use strict"; | ||
var _commander = _interopRequireDefault(require("commander")); | ||
function _commander() { | ||
const data = _interopRequireDefault(require("commander")); | ||
var _module2 = _interopRequireDefault(require("module")); | ||
_commander = function () { | ||
return data; | ||
}; | ||
var _util = require("util"); | ||
return data; | ||
} | ||
var _path = _interopRequireDefault(require("path")); | ||
function _module() { | ||
const data = _interopRequireDefault(require("module")); | ||
var _repl = _interopRequireDefault(require("repl")); | ||
_module = function () { | ||
return data; | ||
}; | ||
var babel = _interopRequireWildcard(require("@babel/core")); | ||
return data; | ||
} | ||
var _vm = _interopRequireDefault(require("vm")); | ||
function _util() { | ||
const data = require("util"); | ||
_util = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _path() { | ||
const data = _interopRequireDefault(require("path")); | ||
_path = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _repl() { | ||
const data = _interopRequireDefault(require("repl")); | ||
_repl = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function babel() { | ||
const data = _interopRequireWildcard(require("@babel/core")); | ||
babel = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _vm() { | ||
const data = _interopRequireDefault(require("vm")); | ||
_vm = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
require("@babel/polyfill"); | ||
var _register = _interopRequireDefault(require("@babel/register")); | ||
function _register() { | ||
const data = _interopRequireDefault(require("@babel/register")); | ||
_register = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _package = _interopRequireDefault(require("../package.json")); | ||
@@ -27,7 +91,7 @@ | ||
var program = new _commander.default.Command("babel-node"); | ||
const program = new (_commander().default.Command)("babel-node"); | ||
function collect(value, previousValue) { | ||
if (typeof value !== "string") return previousValue; | ||
var values = value.split(","); | ||
const values = value.split(","); | ||
return previousValue ? previousValue.concat(values) : values; | ||
@@ -37,2 +101,3 @@ } | ||
program.option("-e, --eval [script]", "Evaluate script"); | ||
program.option("-r, --require [module]", "Require module"); | ||
program.option("-p, --print [code]", "Evaluate script and print result"); | ||
@@ -47,3 +112,3 @@ program.option("-o, --only [globs]", "A comma-separated list of glob patterns to compile", collect); | ||
program.parse(process.argv); | ||
(0, _register.default)({ | ||
(0, _register().default)({ | ||
extensions: program.extensions, | ||
@@ -56,28 +121,28 @@ ignore: program.ignore, | ||
var replPlugin = function replPlugin(_ref) { | ||
var t = _ref.types; | ||
return { | ||
visitor: { | ||
ModuleDeclaration: function ModuleDeclaration(path) { | ||
throw path.buildCodeFrameError("Modules aren't supported in the REPL"); | ||
}, | ||
VariableDeclaration: function VariableDeclaration(path) { | ||
if (path.node.kind !== "var") { | ||
throw path.buildCodeFrameError("Only `var` variables are supported in the REPL"); | ||
} | ||
}, | ||
Program: function Program(path) { | ||
if (path.get("body").some(function (child) { | ||
return child.isExpressionStatement(); | ||
})) return; | ||
path.pushContainer("body", t.expressionStatement(t.identifier("undefined"))); | ||
const replPlugin = ({ | ||
types: t | ||
}) => ({ | ||
visitor: { | ||
ModuleDeclaration(path) { | ||
throw path.buildCodeFrameError("Modules aren't supported in the REPL"); | ||
}, | ||
VariableDeclaration(path) { | ||
if (path.node.kind !== "var") { | ||
throw path.buildCodeFrameError("Only `var` variables are supported in the REPL"); | ||
} | ||
}, | ||
Program(path) { | ||
if (path.get("body").some(child => child.isExpressionStatement())) return; | ||
path.pushContainer("body", t.expressionStatement(t.identifier("undefined"))); | ||
} | ||
}; | ||
}; | ||
var _eval = function _eval(code, filename) { | ||
} | ||
}); | ||
const _eval = function (code, filename) { | ||
code = code.trim(); | ||
if (!code) return undefined; | ||
code = babel.transform(code, { | ||
code = babel().transform(code, { | ||
filename: filename, | ||
@@ -87,3 +152,3 @@ presets: program.presets, | ||
}).code; | ||
return _vm.default.runInThisContext(code, { | ||
return _vm().default.runInThisContext(code, { | ||
filename: filename | ||
@@ -94,19 +159,17 @@ }); | ||
if (program.eval || program.print) { | ||
var code = program.eval; | ||
let code = program.eval; | ||
if (!code || code === true) code = program.print; | ||
global.__filename = "[eval]"; | ||
global.__dirname = process.cwd(); | ||
const module = new (_module().default)(global.__filename); | ||
module.filename = global.__filename; | ||
module.paths = _module().default._nodeModulePaths(global.__dirname); | ||
global.exports = module.exports; | ||
global.module = module; | ||
global.require = module.require.bind(module); | ||
var _module = new _module2.default(global.__filename); | ||
const result = _eval(code, global.__filename); | ||
_module.filename = global.__filename; | ||
_module.paths = _module2.default._nodeModulePaths(global.__dirname); | ||
global.exports = _module.exports; | ||
global.module = _module; | ||
global.require = _module.require.bind(_module); | ||
var result = _eval(code, global.__filename); | ||
if (program.print) { | ||
var output = typeof result === "string" ? result : (0, _util.inspect)(result); | ||
const output = typeof result === "string" ? result : (0, _util().inspect)(result); | ||
process.stdout.write(output + "\n"); | ||
@@ -116,5 +179,5 @@ } | ||
if (program.args.length) { | ||
var args = process.argv.slice(2); | ||
var i = 0; | ||
var ignoreNext = false; | ||
let args = process.argv.slice(2); | ||
let i = 0; | ||
let ignoreNext = false; | ||
args.some(function (arg, i2) { | ||
@@ -127,5 +190,5 @@ if (ignoreNext) { | ||
if (arg[0] === "-") { | ||
var parsedArg = program[arg.slice(2)]; | ||
const parsedArg = program[arg.slice(2)]; | ||
if (parsedArg && parsedArg !== true) { | ||
if (arg === "-r" || arg === "--require" || parsedArg && parsedArg !== true) { | ||
ignoreNext = true; | ||
@@ -139,12 +202,23 @@ } | ||
args = args.slice(i); | ||
var filename = args[0]; | ||
if (!_path.default.isAbsolute(filename)) { | ||
args[0] = _path.default.join(process.cwd(), filename); | ||
if (program.require) { | ||
let requireFileName = program.require; | ||
if (!_path().default.isAbsolute(requireFileName)) { | ||
requireFileName = _path().default.join(process.cwd(), requireFileName); | ||
} | ||
require(requireFileName); | ||
} | ||
const filename = args[0]; | ||
if (!_path().default.isAbsolute(filename)) { | ||
args[0] = _path().default.join(process.cwd(), filename); | ||
} | ||
process.argv = ["node"].concat(args); | ||
process.execArgv.unshift(__filename); | ||
_module2.default.runMain(); | ||
_module().default.runMain(); | ||
} else { | ||
@@ -156,3 +230,3 @@ replStart(); | ||
function replStart() { | ||
_repl.default.start({ | ||
_repl().default.start({ | ||
prompt: "> ", | ||
@@ -167,4 +241,4 @@ input: process.stdin, | ||
function replEval(code, context, filename, callback) { | ||
var err; | ||
var result; | ||
let err; | ||
let result; | ||
@@ -171,0 +245,0 @@ try { |
"use strict"; | ||
var _v8flags = _interopRequireDefault(require("v8flags")); | ||
function _v8flags() { | ||
const data = _interopRequireDefault(require("v8flags")); | ||
var _path = _interopRequireDefault(require("path")); | ||
_v8flags = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _path() { | ||
const data = _interopRequireDefault(require("path")); | ||
_path = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var args = [_path.default.join(__dirname, "_babel-node")]; | ||
var babelArgs = process.argv.slice(2); | ||
var userArgs; | ||
var argSeparator = babelArgs.indexOf("--"); | ||
let args = [_path().default.join(__dirname, "_babel-node")]; | ||
let babelArgs = process.argv.slice(2); | ||
let userArgs; | ||
const argSeparator = babelArgs.indexOf("--"); | ||
@@ -20,6 +36,6 @@ if (argSeparator > -1) { | ||
function getNormalizedV8Flag(arg) { | ||
var matches = arg.match(/--(.+)/); | ||
const matches = arg.match(/--(.+)/); | ||
if (matches) { | ||
return "--" + matches[1].replace(/-/g, "_"); | ||
return `--${matches[1].replace(/-/g, "_")}`; | ||
} | ||
@@ -30,5 +46,5 @@ | ||
(0, _v8flags.default)(function (err, v8Flags) { | ||
babelArgs.forEach(function (arg) { | ||
var flag = arg.split("=")[0]; | ||
(0, _v8flags().default)(function (err, v8Flags) { | ||
babelArgs.forEach(function (arg, index) { | ||
const flag = arg.split("=")[0]; | ||
@@ -48,2 +64,9 @@ switch (flag) { | ||
case "-r": | ||
case "--require": | ||
args.push(flag); | ||
args.push(babelArgs[index + 1]); | ||
delete babelArgs[index + 1]; | ||
break; | ||
case "-gc": | ||
@@ -73,3 +96,3 @@ args.unshift("--expose-gc"); | ||
try { | ||
var kexec = require("kexec"); | ||
const kexec = require("kexec"); | ||
@@ -80,5 +103,5 @@ kexec(process.argv[0], args); | ||
var child_process = require("child_process"); | ||
const child_process = require("child_process"); | ||
var proc = child_process.spawn(process.argv[0], args, { | ||
const proc = child_process.spawn(process.argv[0], args, { | ||
stdio: "inherit" | ||
@@ -95,3 +118,3 @@ }); | ||
}); | ||
process.on("SIGINT", function () { | ||
process.on("SIGINT", () => { | ||
proc.kill("SIGINT"); | ||
@@ -98,0 +121,0 @@ process.exit(1); |
{ | ||
"name": "@babel/node", | ||
"version": "7.0.0-beta.42", | ||
"version": "7.0.0-beta.43", | ||
"description": "Babel command line", | ||
@@ -19,4 +19,4 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"@babel/polyfill": "7.0.0-beta.42", | ||
"@babel/register": "7.0.0-beta.42", | ||
"@babel/polyfill": "7.0.0-beta.43", | ||
"@babel/register": "7.0.0-beta.43", | ||
"commander": "^2.8.1", | ||
@@ -29,7 +29,7 @@ "fs-readdir-recursive": "^1.0.0", | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.42" | ||
"@babel/core": "7.0.0-beta.43" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.42", | ||
"@babel/helper-fixtures": "7.0.0-beta.42" | ||
"@babel/core": "7.0.0-beta.43", | ||
"@babel/helper-fixtures": "7.0.0-beta.43" | ||
}, | ||
@@ -36,0 +36,0 @@ "bin": { |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
9859
286
6
+ Added@babel/code-frame@7.0.0-beta.43(transitive)
+ Added@babel/core@7.0.0-beta.43(transitive)
+ Added@babel/generator@7.0.0-beta.43(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.43(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.43(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.43(transitive)
+ Added@babel/helpers@7.0.0-beta.43(transitive)
+ Added@babel/highlight@7.0.0-beta.43(transitive)
+ Added@babel/polyfill@7.0.0-beta.43(transitive)
+ Added@babel/register@7.0.0-beta.43(transitive)
+ Added@babel/template@7.0.0-beta.43(transitive)
+ Added@babel/traverse@7.0.0-beta.43(transitive)
+ Added@babel/types@7.0.0-beta.43(transitive)
+ Addedbabylon@7.0.0-beta.43(transitive)
- Removed@babel/code-frame@7.0.0-beta.42(transitive)
- Removed@babel/core@7.0.0-beta.42(transitive)
- Removed@babel/generator@7.0.0-beta.42(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.42(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.42(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.42(transitive)
- Removed@babel/helpers@7.0.0-beta.42(transitive)
- Removed@babel/highlight@7.0.0-beta.42(transitive)
- Removed@babel/polyfill@7.0.0-beta.42(transitive)
- Removed@babel/register@7.0.0-beta.42(transitive)
- Removed@babel/template@7.0.0-beta.42(transitive)
- Removed@babel/traverse@7.0.0-beta.42(transitive)
- Removed@babel/types@7.0.0-beta.42(transitive)
- Removedbabylon@7.0.0-beta.42(transitive)