PlatformIO Community

How to run gulp in extra script in subfolder of my platformio project

I would like to embed my web site inside PROGMEM for my platformio project.

In order to do that, I u se gulp script. My script is okay and works well.

I would like to run my gulp script at each build using pre-script.

The main problem I encounter is that the gulp command has to be executed in subfolder of my platformio project.

Here is extract of my platformio.ini

extra_scripts = 
pre:pre_extra_script.py
post:extra_script.py

Here is pre_extra_script.py

Import("env")

# access to global build environment
print(env)

# Build actions

print("BEFORE BUILD----------------------")

print("Running gulp")
env.Execute("web/gulp")

The problem comes from env.Execute command which doesn’t works. I don’t know how to run “gulp” command in “./web” folder.

How I can ask to env.Execute commande to run gulp command inside web subfolder ?

Is there an executable file inside the web folder called gulp? Or is gulp a standalone command and just needs the current working directory to be web?

Have you tried something like

import subprocess

subprocess.check_output(["gulp"], cwd="web")

Refer e.g. python docs and example. Also subprocess_call() can be used.

You can also just try and env.Execute("cd web && gulp") maybe.

So simple !!!

env.Execute("cd web && gulp")

works perfectly !
Thanks