Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.4.8
- compiler: ghc-9.8.4
compilerKind: ghc
compilerVersion: 9.4.8
compilerVersion: 9.8.4
setup-method: ghcup
allow-failure: false
fail-fast: false
Expand Down Expand Up @@ -150,7 +150,6 @@ jobs:
echo "package lineman" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
constraints: http-client-tls == 0.3.6.3
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(lineman)$/; }' >> cabal.project.local
cat cabal.project
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
`lineman` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].

## 1.0.4

* Land on `typed-base`

## 1.0.3

* Add justfile
Expand Down
5 changes: 1 addition & 4 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
packages: .

constraints:
http-client-tls == 0.3.6.3
packages: .
6 changes: 3 additions & 3 deletions hie.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cradle:
cabal:
- path: "./src"
- path: "src"
component: "lib:lineman"

- path: "./app/Main.hs"
- path: "app/Main.hs"
component: "lineman:exe:lineman"

- path: "./test"
- path: "test"
component: "lineman:test:lineman-test"
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GHC_VERSION := "9.4.8"
GHC_VERSION := "9.8.4"

# prepare the environment for the project
prepare:
Expand Down
9 changes: 5 additions & 4 deletions lineman.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: lineman
version: 1.0.3
version: 1.0.4
synopsis: traverse directory and run command
description:
Lineman traverses directory recursively and run command by condition
Expand All @@ -19,14 +19,14 @@ extra-doc-files:
CHANGELOG.md
README.md

tested-with: GHC ==9.4.8
tested-with: GHC ==9.8.4

source-repository head
type: git
location: https://github.com/metaxis/lineman.git

common common-options
build-depends: base ^>=4.17.2.1
build-depends: base ^>=4.19.2.0
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-uni-patterns
-Wincomplete-record-updates -Wredundant-constraints
Expand Down Expand Up @@ -73,11 +73,12 @@ library
, path
, path-io
, pretty-simple
, process
, typed-process
, safe-exceptions
, stm
, text
, transformers-base
, witch

executable lineman
import: common-options
Expand Down
18 changes: 13 additions & 5 deletions src/Lineman.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import Control.Monad.IO.Class (liftIO)
import Control.Monad.Reader (asks)
import Cook (prepareConditions)
import qualified Data.Text as T
import GHC.IO.Exception (ExitCode (..))
import Log (logDebug, logError, logInfo)
import Path.IO (doesDirExist, doesFileExist, listDir, listDirRecur)
import Path.Posix (Abs, Dir, File, Path, PathException, Rel, fileExtension, toFilePath, (</>))
import System.Process (CreateProcess (..), proc, readCreateProcessWithExitCode)
import System.Process.Extra (showCommandForUser)
import System.Process.Typed
import Types (App, Env (..))
import Witch
import Prelude hiding (log)

launchAction :: App ()
Expand Down Expand Up @@ -57,15 +57,23 @@ getDirsForCommand target files dirs exts = do
action :: FilePath -> [String] -> Path Abs Dir -> App ExitCode
action commandName args path = do
-- liftIO $ threadDelay 500_000 -- 0.5 seconds
let dateConfig :: ProcessConfig () () ()
dateConfig = setWorkingDir (toFilePath path) $ proc commandName args
(exitCode, stdout, stderr) <-
liftIO $
readCreateProcessWithExitCode (proc commandName args){cwd = Just $ toFilePath path} ""
readProcess dateConfig
case stderr of
"" -> pure ()
err -> logError $ "In " <> T.pack (show path) <> " occurred stderr: \n" <> T.strip (T.pack err)
err -> logError $ "In "
<> T.pack (show path)
<> " occurred stderr: \n"
<> T.strip (unsafeInto @T.Text $ into @Utf8L err)
case stdout of
"" -> pure ()
out -> logDebug $ "In " <> T.pack (show path) <> " occurred stdout: \n" <> T.pack out
out -> logDebug $ "In "
<> T.pack (show path)
<> " occurred stdout: \n"
<> unsafeInto @T.Text (into @Utf8L out)
logDebug $ T.pack (show exitCode)
pure exitCode

Expand Down