@@ -155,6 +155,7 @@ impl<T: Trigger> FactorsTriggerCommand<T> {
155
155
// Required env vars
156
156
let working_dir = std:: env:: var ( SPIN_WORKING_DIR ) . context ( SPIN_WORKING_DIR ) ?;
157
157
let locked_url = std:: env:: var ( SPIN_LOCKED_URL ) . context ( SPIN_LOCKED_URL ) ?;
158
+ let local_app_dir = std:: env:: var ( SPIN_LOCAL_APP_DIR ) . ok ( ) ;
158
159
159
160
let follow_components = self . follow_components ( ) ;
160
161
@@ -192,6 +193,7 @@ impl<T: Trigger> FactorsTriggerCommand<T> {
192
193
TriggerAppOptions {
193
194
runtime_config_file : self . runtime_config_file . as_deref ( ) ,
194
195
state_dir : self . state_dir . as_deref ( ) ,
196
+ local_app_dir : local_app_dir. as_deref ( ) ,
195
197
initial_key_values : self . key_values ,
196
198
allow_transient_write : self . allow_transient_write ,
197
199
follow_components,
@@ -268,6 +270,8 @@ pub struct TriggerAppOptions<'a> {
268
270
runtime_config_file : Option < & ' a Path > ,
269
271
/// Path to the state directory.
270
272
state_dir : Option < & ' a str > ,
273
+ /// Path to the local app directory.
274
+ local_app_dir : Option < & ' a str > ,
271
275
/// Initial key/value pairs to set in the app's default store.
272
276
initial_key_values : Vec < ( String , String ) > ,
273
277
/// Whether to allow transient writes to mounted files
@@ -306,12 +310,17 @@ impl<T: Trigger> TriggerAppBuilder<T> {
306
310
307
311
// Hardcode `use_gpu` to true for now
308
312
let use_gpu = true ;
309
- // Make sure `--state-dir=""` unsets the state dir
310
- let state_dir = options. state_dir . filter ( |s| !s. is_empty ( ) ) . map ( Path :: new) ;
313
+ let state_dir = match options. state_dir {
314
+ // Make sure `--state-dir=""` unsets the state dir
315
+ Some ( s) if s. is_empty ( ) => None ,
316
+ Some ( s) => Some ( PathBuf :: from ( s) ) ,
317
+ // Default to `.spin/` in the local app dir
318
+ None => options. local_app_dir . map ( |d| Path :: new ( d) . join ( ".spin" ) ) ,
319
+ } ;
311
320
let runtime_config =
312
321
ResolvedRuntimeConfig :: < TriggerFactorsRuntimeConfig > :: from_optional_file (
313
322
options. runtime_config_file ,
314
- state_dir,
323
+ state_dir. as_deref ( ) ,
315
324
use_gpu,
316
325
) ?;
317
326
0 commit comments