ui5-tooling icon indicating copy to clipboard operation
ui5-tooling copied to clipboard

TaskUtil to expose the current tasks name

Open kristian opened this issue 4 years ago • 0 comments

Describe the solution you'd like

For custom task implementations according to [1] it would be helpful to either have TaskUtil expose a getTaskName or have parameters.options contain the taskName.

Describe alternatives you've considered

No alternatives available afaik, in a task function, you cannot find out the task you are running in

Additional context

Imagine you have a decomment-html task. The general implementation of the task also allows to remove comments from XML files however, with a slightly different ruleset. Thus it would make sense to acutally link two custom tasks to the same function like so:

specVersion: "2.4"
kind: extension
metadata:
  name: decomment-html
type: task
task:
  path: lib/decomment.js
---
specVersion: "2.4"
kind: extension
metadata:
  name: decomment-xml
type: task
task:
  path: lib/decomment.js

However the decomment module has no way of knowing the task name, thus it cannot differentiate between both calls. Currently it is required to also create two seperate "wrapper" JavaScript files (decommentHtml.js and decommentXml.js).

[1] https://sap.github.io/ui5-tooling/pages/extensibility/CustomTasks/

kristian avatar Aug 20 '21 11:08 kristian