()
| 10 | import { spawnAsync } from '../utils/shell/spawn'; |
| 11 | |
| 12 | async function runCustomJsFunctionAsync(): Promise<void> { |
| 13 | const customJavascriptFunctionModulePath = process.argv[2]; |
| 14 | const functionArgs = process.argv[3]; |
| 15 | |
| 16 | assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required'); |
| 17 | assert(functionArgs, 'serializedFunctionParams is required'); |
| 18 | |
| 19 | let serializedFunctionArguments: SerializedCustomBuildFunctionArguments; |
| 20 | try { |
| 21 | serializedFunctionArguments = JSON.parse(functionArgs); |
| 22 | } catch (e) { |
| 23 | console.error('Failed to parse serializedFunctionParams'); |
| 24 | throw e; |
| 25 | } |
| 26 | |
| 27 | const logger = createLogger({ |
| 28 | name: 'customFunctionLogger', |
| 29 | streams: [ |
| 30 | { |
| 31 | type: 'raw', |
| 32 | stream: { |
| 33 | write: (rec: any) => { |
| 34 | if (rec) { |
| 35 | switch (rec.level) { |
| 36 | case 20: // Debug level |
| 37 | if (rec.msg) { |
| 38 | console.debug(rec.msg); |
| 39 | } |
| 40 | break; |
| 41 | case 30: // Info level |
| 42 | if (rec.msg) { |
| 43 | console.log(rec.msg); |
| 44 | } |
| 45 | break; |
| 46 | case 40: // Warn level |
| 47 | if (rec.msg) { |
| 48 | console.warn(rec.msg); |
| 49 | } |
| 50 | break; |
| 51 | case 50: // Error level |
| 52 | case 60: // Fatal level |
| 53 | if (rec.msg) { |
| 54 | console.error(rec.msg); |
| 55 | } |
| 56 | break; |
| 57 | default: |
| 58 | break; |
| 59 | } |
| 60 | } |
| 61 | }, |
| 62 | }, |
| 63 | }, |
| 64 | ], |
| 65 | }); |
| 66 | |
| 67 | const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger); |
| 68 | const inputs = deserializeInputs(serializedFunctionArguments.inputs); |
| 69 | const outputs = Object.fromEntries( |
no test coverage detected
searching dependent graphs…