|
|
@@ -242,13 +242,40 @@ export async function expandAndRunTask(meta, config) {
|
|
|
|
|
|
if (config.stateSelectors) {
|
|
|
if (config.expand === false) {
|
|
|
- const inputs = selectState(config.stateSelectors, meta).map(
|
|
|
- stateItem => stateItem.value.detail,
|
|
|
+ const pathsToStrip = (config.stripPaths || []).map(path =>
|
|
|
+ expandTilde(path),
|
|
|
)
|
|
|
+ const inputs = selectState(config.stateSelectors, meta).map(stateItem => {
|
|
|
+ return stateItem.value.detail
|
|
|
+ ? stateItem.value.detail
|
|
|
+ : stateItem.value
|
|
|
+ })
|
|
|
+ const decorations = {
|
|
|
+ ...(config.buildFilePath
|
|
|
+ ? {
|
|
|
+ fileOutputPath: path.join(
|
|
|
+ meta.opts.outDir,
|
|
|
+ config.outputDir,
|
|
|
+ replaceFileExtension(
|
|
|
+ removeBasePaths(
|
|
|
+ pathsToStrip,
|
|
|
+ config.outputFileName || config.name,
|
|
|
+ ),
|
|
|
+ config.outputFileExtension,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ }
|
|
|
+ : {}),
|
|
|
+ }
|
|
|
+ const jobConfig = {
|
|
|
+ ...config,
|
|
|
+ ...decorations,
|
|
|
+ inputs,
|
|
|
+ }
|
|
|
const jobId = config.jobId || config.name
|
|
|
const taskResult = await runTask({
|
|
|
meta,
|
|
|
- config: { ...config, inputs },
|
|
|
+ config: { ...jobConfig },
|
|
|
jobId,
|
|
|
})
|
|
|
return [taskResult]
|
|
|
@@ -268,10 +295,21 @@ export async function processTask(meta, task) {
|
|
|
const taskResult = await expandAndRunTask(meta, task)
|
|
|
const cached = taskResult.filter(taskResult => taskResult.fromCache)
|
|
|
const processed = taskResult.filter(taskResult => !taskResult.fromCache)
|
|
|
- const resources = taskResult.reduce(
|
|
|
- (obj, tResult) => (tResult.ref ? { ...obj, [tResult.ref]: tResult } : obj),
|
|
|
- {},
|
|
|
- )
|
|
|
+ const resourcesWithRef = taskResult.filter(tResult => tResult.ref)
|
|
|
+ const hasExpandableInputs =
|
|
|
+ (task.inputFiles?.length || task.stateSelectors?.length) &&
|
|
|
+ task.expand !== false
|
|
|
+ const shouldCollapseResources =
|
|
|
+ resourcesWithRef.length === 1 &&
|
|
|
+ taskResult.length === 1 &&
|
|
|
+ !hasExpandableInputs
|
|
|
+ const resources = shouldCollapseResources
|
|
|
+ ? resourcesWithRef[0]
|
|
|
+ : resourcesWithRef.reduce(
|
|
|
+ (obj, tResult) =>
|
|
|
+ tResult.ref ? { ...obj, [tResult.ref]: tResult } : obj,
|
|
|
+ {},
|
|
|
+ )
|
|
|
const endTime = performance.now()
|
|
|
const timeTaken = endTime - startTime
|
|
|
const hrTime =
|