* 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)
| 91 | * @throws {VMError} If the compiler is unknown or the coffee script module was needed and couldn't be found. |
| 92 | */ |
| 93 | function 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 | |
| 116 | exports.removeShebang = removeShebang; |
| 117 | exports.lookupCompiler = lookupCompiler; |
no test coverage detected
searching dependent graphs…