https://pulumi.com logo
#general
Title
# general
f

flat-guitar-86436

09/12/2019, 5:01 PM
can I execute cmd commands in a pulumi program? I would like to
git clone
a helm chart and run it after
b

better-rainbow-14549

09/12/2019, 5:21 PM
yeah just make sure its awaited or synchronous and it will all be fine just like any other app
f

flat-guitar-86436

09/12/2019, 5:52 PM
what’s the… module / syntax to execute a command?
b

better-rainbow-14549

09/12/2019, 5:53 PM
import child_process i guess
f

flat-guitar-86436

09/12/2019, 6:04 PM
oh, so like a node app? 🤔
there is a Module called cmd in pulumi not sure
b

better-rainbow-14549

09/12/2019, 6:06 PM
if you're using typescript/node you'd use that yeah, python use whatever the equivalent is
c

clever-sunset-76585

09/12/2019, 6:42 PM
oh, so like a node app?
Yes, for JS and TS. Here’s an example from a recent personal project of mine: https://github.com/praneetloke/GarageDoorMonitor/blob/master/infrastructure/projectBuilder.ts. I am invoking
dotnet publish
, though I am doing it using the synchronous version of
spawn
. I am doing that because the async version only accepts a callback and not async/await, which would have required me to create a promise and manually resolve/reject the promise. I didn’t want to do all that, but you could if you wanted to. I also think synchronous exec is fine here.
🔥 1
f

flat-guitar-86436

09/12/2019, 7:12 PM
@clever-sunset-76585 this is exactly what I wanted, thanks for the example!
👍 1
3 Views