Fix build directory locking
@@ -46,7 +46,6 @@ pub struct ProjectCompiler<IO> {
options: Options,
ids: UniqueIdGenerator,
io: IO,
- lock: NamedLock,
/// We may want to silence subprocess stdout if we are running in LSP mode.
/// The language server talks over stdio so printing would break that.
pub silence_subprocess_stdout: bool,
@@ -71,9 +70,6 @@ where
.map(|p| (p.name.to_string(), p))
.collect();
- // TODO can this return a result?
- let lock = NamedLock::create("gleam-compile")?;
-
Self {
importable_modules: im::HashMap::new(),
defined_modules: im::HashMap::new(),
@@ -84,8 +80,7 @@ where
packages,
options,
config,
- io,
- lock
+ io
}
}
@@ -119,10 +114,8 @@ where
/// Returns the compiled information from the root package
pub fn compile(&mut self) -> Result<Package> {
- let lock_guard = self.lock.try_lock();
- if(lock_guard.is_err()) {
- return lock_guard // TODO fix return type
- }
+ let lock = NamedLock::create("gleam-compile").expect("Could not lock build directory");
+ let _lock_guard = lock.try_lock().expect("Could not lock build directory");
self.check_gleam_version()?;
self.compile_dependencies()?;
