MCPcopy
hub / github.com/patriksimek/vm2 / lookupCompiler

Function lookupCompiler

lib/compiler.js:93–114  ·  view source on GitHub ↗

* Look up the compiler for a specific name. * * @private * @param {(string|compileCallback)} compiler - A compile callback or the name of the compiler. * @param {Object} [options] - Optional compiler options. * @return {compileCallback} The resolved compiler. * @throws {VMError} If the compile

(compiler, options)

Source from the content-addressed store, hash-verified

91 * @throws {VMError} If the compiler is unknown or the coffee script module was needed and couldn't be found.
92 */
93function lookupCompiler(compiler, options) {
94 if ('function' === typeof compiler) return compiler;
95 switch (compiler) {
96 case 'coffeescript':
97 case 'coffee-script':
98 case 'cs':
99 case 'text/coffeescript':
100 return getCoffeeScriptCompiler(options);
101 case 'javascript':
102 case 'java-script':
103 case 'js':
104 case 'text/javascript':
105 return jsCompiler;
106 case 'typescript':
107 case 'type-script':
108 case 'ts':
109 case 'text/typescript':
110 return getTypeScriptCompiler(options);
111 default:
112 throw new VMError(`Unsupported compiler '${compiler}'.`);
113 }
114}
115
116exports.removeShebang = removeShebang;
117exports.lookupCompiler = lookupCompiler;

Callers 2

constructorMethod · 0.85
constructorMethod · 0.85

Calls 2

getCoffeeScriptCompilerFunction · 0.85
getTypeScriptCompilerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…