ChromaticHQ / calliope

An opinionated yet extensible toolset to handle common front-end tasks
3 stars 0 forks source link

GH-18 Use registered Gulp task instead of requiring task file #19

Closed agarzola closed 2 years ago

agarzola commented 2 years ago

Description

This PR updates Calliope’s internal watch task to use whatever task is currently registered with Gulp with a given name, instead of attempting to require a file with that name.

Motivation / Context

The current strategy assumes that the task being processed is defined within Calliope itself, which is not always the case. In the case of a custom pipeline defined in a downstream project, the start command fails catastrophically. Arguably worse, in the case of a pipeline task override, the process simply picks up Calliope’s local task and uses that to generate files instead of the downstream project’s override.

Testing Instructions / How This Has Been Tested

Two options here:

  1. Trust me and the screenshots below.
  2. Trust me, yet still check this yourself locally.

If you’re still reading: congratulations! Here’s what you need to do:

  1. Clone this branch locally.
  2. Run yarn link from the root of this repo.
  3. Clone the chromatichq-eleventy repo.
  4. From chromatichq-eleventy, run:
    1. yarn install
    2. yarn start - Confirm you see the error shown in the screenshots below (or the ticket).
    3. yarn link @chromatichq/calliope
    4. yarn start - Confirm you no longer see the error.
    5. yarn unlink @chromatichq/calliope && yarn install - This is just to make sure you don’t forget to unlink it later.

Screenshots

The problem The fix
image image
Notice in the stack trace that Calliope’s internal watch appears to be trying to load an ./eleventy file relative to itself. No errors! This is with my local (and fixed!) Calliope linked via yarn link @chromatichq/calliope.

Documentation

n/a

agarzola commented 2 years ago

@adamzimmermann Just fixed it! See 2a9540c. Thanks!