@expo/steps
Advanced tools
Comparing version 1.0.31 to 1.0.32
@@ -13,2 +13,2 @@ import { BuildStepFunction } from '../BuildStep.js'; | ||
} | ||
export declare function createCustomFunctionCall(customFunctionModulePath: string): BuildStepFunction; | ||
export declare function createCustomFunctionCall(rawCustomFunctionModulePath: string): BuildStepFunction; |
@@ -13,2 +13,2 @@ import { BuildStepFunction } from '../BuildStep.js'; | ||
} | ||
export declare function createCustomFunctionCall(customFunctionModulePath: string): BuildStepFunction; | ||
export declare function createCustomFunctionCall(rawCustomFunctionModulePath: string): BuildStepFunction; |
import path from 'path'; | ||
import { createContext } from 'this-file'; | ||
import fs from 'fs-extra'; | ||
import { spawnAsync } from './shell/spawn.js'; | ||
const thisFileCtx = createContext(); | ||
export const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts'); | ||
export function createCustomFunctionCall(customFunctionModulePath) { | ||
export function createCustomFunctionCall(rawCustomFunctionModulePath) { | ||
return async (ctx, { env, inputs, outputs }) => { | ||
let customFunctionModulePath = rawCustomFunctionModulePath; | ||
if (!(await fs.exists(ctx.global.projectSourceDirectory))) { | ||
const relative = path.relative(path.resolve(ctx.global.projectSourceDirectory), customFunctionModulePath); | ||
customFunctionModulePath = path.resolve(path.join(ctx.global.projectTargetDirectory, relative)); | ||
} | ||
const serializedArguments = { | ||
@@ -14,13 +20,18 @@ env, | ||
}; | ||
await spawnAsync('node', [ | ||
path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'), | ||
customFunctionModulePath, | ||
JSON.stringify(serializedArguments), | ||
], { | ||
logger: ctx.logger, | ||
cwd: ctx.workingDirectory, | ||
env, | ||
}); | ||
try { | ||
await spawnAsync('node', [ | ||
path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'), | ||
customFunctionModulePath, | ||
JSON.stringify(serializedArguments), | ||
], { | ||
logger: ctx.logger, | ||
cwd: ctx.workingDirectory, | ||
env, | ||
}); | ||
} | ||
catch { | ||
throw new Error(`Custom function exited with non-zero exit code.`); | ||
} | ||
}; | ||
} | ||
//# sourceMappingURL=customFunction.js.map |
{ | ||
"name": "@expo/steps", | ||
"type": "module", | ||
"version": "1.0.31", | ||
"version": "1.0.32", | ||
"main": "./dist_commonjs/index.cjs", | ||
@@ -66,3 +66,3 @@ "types": "./dist_esm/index.d.ts", | ||
}, | ||
"gitHead": "349e6f330c97977009cf501992f141aefbc01317" | ||
"gitHead": "8c5a3b94a25d25af83fd3edd26f0aa0f92899455" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
527358
4616
15