Search code examples
typescriptgulp-4

How can I use old style task names with the new gulp task api?


According to https://gulpjs.com/docs/en/api/task the new way to create tasks is not gulp.task("xyz" ...) but instead use exports.build = build; The problem with this approach is, that I can't use old task names like feature:build, feature:watch anymore, because I can only export valid JS identifiers.

Is there any way to achieve this with the new method?


Solution

  • Found the answer by accident.

    Each TaskFunction has a property displayName, which does not just change the name that is used to display the task in the task list or when running, but also the task name that you need to pass gulp in order to run it.

    So it would be something like:

    export const myTask :TaskFunction = () => ...;
    myTask.displayName = "run:task";