I'd like to run a script to seed data and create u...
# help
a
I'd like to run a script to seed data and create users (if they don't exist) after successful sst build. Any ideas?
f
Hey @Abdul Taleb, currently I’ve seen ppl do it in their command line, ie. make the npm deploy script:
Copy code
"deploy": "sst deploy && node seedDB.js"
Does that work for you?
a
That works
To add to this question how can i set environment variables that the script needs to access, also how can I only do this in local dev?
is the
IS_LOCAL
flag available within the sst stack?
f
yup, it is
a
I tested this out with
sst start
and since it's an ongoing process, the script doesn't run until I
ctrl + c
. Trying to write a script using
child_process
but haven't gotten to a working solution.
f
Actually, let me see if I can do something on the SST side.
I will add a
sst.Script
construct, and you can configure it to run after the other resoruces are deployed.
I can try to get this done by today or tmr.