git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1364 from mjgpy3/1176_warn_about_non_existent_files

Resolves #1176. Warn when psc is given globs that match no files.

commit0b2ec9db256bd8faa971bc4f1713e83150596c12 authorPhil Freeman <paf31@cantab.net> dateWed 12 Aug 2015, 11:01 (11 years ago) parent93adc069a96f99
1 file changed+14−2
psc/Main.hs+14−2
psc/Main.hs+14−2
@@ -52,12 +52,12 @@ data InputOptions = InputOptions
5252
5353compile :: PSCMakeOptions -> IO ()
5454compile (PSCMakeOptions inputGlob inputForeignGlob outputDir opts usePrefix) = do
55− input <- concat <$> mapM glob inputGlob
55+ input <- globWarningOnMisses warnFileTypeNotFound inputGlob
5656 when (null input) $ do
5757 hPutStrLn stderr "psc: No input files."
5858 exitFailure
5959 moduleFiles <- readInput (InputOptions input)
60− inputForeign <- concat <$> mapM glob inputForeignGlob
60+ inputForeign <- globWarningOnMisses warnFileTypeNotFound inputForeignGlob
6161 foreignFiles <- forM inputForeign (\inFile -> (inFile,) <$> readFile inFile)
6262 case runWriterT (parseInputs moduleFiles foreignFiles) of
6363 Left errs -> do
@@ -78,6 +78,18 @@ compile (PSCMakeOptions inputGlob inputForeignGlob outputDir opts usePrefix) = d
7878 hPutStrLn stderr (P.prettyPrintMultipleWarnings (P.optionsVerboseErrors opts) warnings')
7979 exitSuccess
8080
81+warnFileTypeNotFound :: String -> IO ()
82+warnFileTypeNotFound = hPutStrLn stderr . ((++) "psc: No files found using pattern: ")
83+
84+globWarningOnMisses :: (String -> IO ()) -> [FilePath] -> IO [FilePath]
85+globWarningOnMisses warn = concatMapM globWithWarning
86+ where
87+ globWithWarning pattern = do
88+ paths <- glob pattern
89+ when (null paths) $ warn pattern
90+ return paths
91+ concatMapM f = liftM concat . mapM f
92+
8193readInput :: InputOptions -> IO [(Either P.RebuildPolicy FilePath, String)]
8294readInput InputOptions{..} = forM ioInputFiles $ \inFile -> (Right inFile, ) <$> readFile inFile
8395