@@ -22,6 +22,7 @@ import qualified System.Process as System
22
22
import qualified System.Exit as System
23
23
import qualified Data.Text as Text
24
24
import System.Directory
25
+ import System.FilePath ((</>) , takeDirectory , takeFileName , dropTrailingPathSeparator )
25
26
26
27
import Transient.Move
27
28
@@ -32,7 +33,7 @@ initialState = State
32
33
{ compiledOutput = " "
33
34
, compilationError = " No project has been loaded yet, try opening one?"
34
35
, projectPath = " "
35
- , workingFile = " / src/Main.hs"
36
+ , workingFile = " src/Main.hs"
36
37
}
37
38
38
39
lastProjectFile :: FilePath
@@ -51,7 +52,7 @@ update Compile state = do
51
52
52
53
writeWorkingFile :: String -> State -> IO ()
53
54
writeWorkingFile content state = do
54
- let fullPath = projectPath state ++ workingFile state
55
+ let fullPath = projectPath state </> workingFile state
55
56
fileExists <- doesFileExist fullPath
56
57
when fileExists (writeCode fullPath content)
57
58
@@ -108,23 +109,14 @@ preprocessOutput out =
108
109
109
110
makeNewProject :: String -> IO ()
110
111
makeNewProject path = do
111
- let projectName = dirname path
112
- let parentDir = parent path
112
+ let p = dropTrailingPathSeparator path
113
+ let projectName = takeFileName p
114
+ let parentDir = takeDirectory p
113
115
putStrLn path
114
116
putStrLn projectName
115
117
putStrLn parentDir
116
118
_ <- runCommand (" new " ++ projectName ++ " " ++ templateURL) parentDir
117
119
return ()
118
- where
119
- dirname p = init p
120
- |> reverse
121
- |> takeWhile (/= ' /' )
122
- |> reverse
123
- parent p = init p
124
- |> reverse
125
- |> dropWhile (/= ' /' )
126
- |> tail
127
- |> reverse
128
120
129
121
runCommand :: String -> FilePath -> IO (System. ExitCode , String , String )
130
122
runCommand command projPath = do
0 commit comments