on master help sign in
check canonical current path
commit8dee05ad410f12b1d2cb79eb18cc67c44322d0d3 authorhsloan <ishaqsloan@gmail.com> dateFri 30 Nov 2018, 23:07 (8 years ago) parentee5acbb
1 file changed+6−4
lib/command/src/Obelisk/Command/Thunk.hs+6−4
lib/command/src/Obelisk/Command/Thunk.hs+6−4
@@ -379,10 +379,12 @@ createThunkWithLatest target s = do
379379 }
380380
381381updateThunkToLatest :: MonadObelisk m => FilePath -> m ()
382−updateThunkToLatest target = withSpinner' ("Updating thunk " <> T.pack target <> " to latest") (pure $ const $ "Thunk " <> T.pack target <> " updated to latest") $
383− case target of
384− "." -> failWith "ob thunk update directory cannot be '.'"
385− _ -> do
382+updateThunkToLatest target = withSpinner' ("Updating thunk " <> T.pack target <> " to latest") (pure $ const $ "Thunk " <> T.pack target <> " updated to latest") $ do
383+ canonicalCurrentPath <- liftIO $ canonicalizePath "."
384+ canonicalTarget <- liftIO $ canonicalizePath target
385+ if canonicalCurrentPath == canonicalTarget
386+ then failWith "ob thunk update directory cannot be '.'"
387+ else do
386388 (overwrite, ptr) <- readThunk target >>= \case
387389 Left err -> failWith $ T.pack $ "thunk update: " <> show err
388390 Right c -> case c of