Server IP : 92.205.26.207 / Your IP : 216.73.216.16 Web Server : Apache System : Linux 207.26.205.92.host.secureserver.net 4.18.0-553.60.1.el8_10.x86_64 #1 SMP Thu Jul 10 04:01:16 EDT 2025 x86_64 User : zikryat ( 1002) PHP Version : 8.3.23 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/zikryat/public_html/node_modules/vm2/lib/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
'use strict'; const { VMError } = require('./bridge'); let cacheCoffeeScriptCompiler; /** * Returns the cached coffee script compiler or loads it * if it is not found in the cache. * * @private * @return {compileCallback} The coffee script compiler. * @throws {VMError} If the coffee-script module can't be found. */ function getCoffeeScriptCompiler() { if (!cacheCoffeeScriptCompiler) { try { // The warning generated by webpack can be disabled by setting: // ignoreWarnings[].message = /Can't resolve 'coffee-script'/ /* eslint-disable-next-line global-require */ const coffeeScript = require('coffee-script'); cacheCoffeeScriptCompiler = (code, filename) => { return coffeeScript.compile(code, {header: false, bare: true}); }; } catch (e) { throw new VMError('Coffee-Script compiler is not installed.'); } } return cacheCoffeeScriptCompiler; } /** * Remove the shebang from source code. * * @private * @param {string} code - Code from which to remove the shebang. * @return {string} code without the shebang. */ function removeShebang(code) { if (!code.startsWith('#!')) return code; return '//' + code.substring(2); } /** * The JavaScript compiler, just a identity function. * * @private * @type {compileCallback} * @param {string} code - The JavaScript code. * @param {string} filename - Filename of this script. * @return {string} The code. */ function jsCompiler(code, filename) { return removeShebang(code); } /** * Look up the compiler for a specific name. * * @private * @param {(string|compileCallback)} compiler - A compile callback or the name of the compiler. * @return {compileCallback} The resolved compiler. * @throws {VMError} If the compiler is unknown or the coffee script module was needed and couldn't be found. */ function lookupCompiler(compiler) { if ('function' === typeof compiler) return compiler; switch (compiler) { case 'coffeescript': case 'coffee-script': case 'cs': case 'text/coffeescript': return getCoffeeScriptCompiler(); case 'javascript': case 'java-script': case 'js': case 'text/javascript': return jsCompiler; default: throw new VMError(`Unsupported compiler '${compiler}'.`); } } exports.removeShebang = removeShebang; exports.lookupCompiler = lookupCompiler;