Skip to content

Commit

Permalink
4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Oct 3, 2023
1 parent b7d4756 commit af89d2a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.0.0

Moved the `currentWorkingDirectory` to the main `Shikensu` module so that it can use the `Error` type instead for ease of use.

## 3.0.0

* Added `Shikensu.perform`
Expand Down
2 changes: 1 addition & 1 deletion docs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gren.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "icidasset/shikensu-gren",
"summary": "Run a sequence of functions on in-memory representations of files",
"license": "BSD-3-Clause",
"version": "3.0.0",
"version": "4.0.0",
"exposed-modules": [
"Shikensu",
"Shikensu.Bundle",
Expand Down
36 changes: 28 additions & 8 deletions src/Shikensu.gren
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
module Shikensu exposing ( Program, Task, list, perform, program, programs, read, write, writeDefinition )
module Shikensu exposing ( Program, Task, currentWorkingDirectory, list, perform, program, programs, read, write, writeDefinition )

{-|

# 🚀

@docs program, programs, Program, list, perform, Task
@docs program, programs, Program, Task, list, perform


# IO

@docs read, write, writeDefinition


# 🛠️

@docs currentWorkingDirectory

-}

import Bytes.Encode
Expand Down Expand Up @@ -153,8 +158,7 @@ If you run `./binary/app` the resulting path will be `~/code/example/`.
list : FileSystem.Permission -> Focus -> Task
list fsPermission focus =
fsPermission
|> Path.currentWorkingDirectory
|> Task.mapError neverError
|> currentWorkingDirectory
|> Task.andThen
(\cwd ->
let
Expand Down Expand Up @@ -327,12 +331,28 @@ writeDefinition permission destinationDirectory def =



-- ㊙️
-- 🛠️


{-| Get the absolute directory path of the current working directory.
-}
currentWorkingDirectory : FileSystem.Permission -> Task.Task Error (Path Directory)
currentWorkingDirectory permission =
permission
|> FileSystem.currentWorkingDirectory
|> Task.map
(\a ->
if String.endsWith "/" a then
a
else
a ++ "/"
)
|> Task.map (Path.fromPosix >> Path.unwrap >> Path.directory)
|> Task.mapError (\_ -> ErrorMessage "Never ever have I 🤫")


neverError : Never -> Error
neverError _ =
ErrorMessage "Never ever have I 🤫"

-- ㊙️


recursiveList : FileSystem.Permission -> Path Directory -> Path Directory -> Task.Task Error (Array Definition)
Expand Down
22 changes: 2 additions & 20 deletions src/Shikensu/Path.gren
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Shikensu.Path exposing ( Path, Directory, File, Encapsulated, Kind(..), currentWorkingDirectory, directory, length, file, fromPosix, toPosix, encapsulate, combine, kind, map, unwrap )
module Shikensu.Path exposing ( Path, Directory, File, Encapsulated, Kind(..), directory, length, file, fromPosix, toPosix, encapsulate, combine, kind, map, unwrap )

{-|

Expand All @@ -9,7 +9,7 @@ module Shikensu.Path exposing ( Path, Directory, File, Encapsulated, Kind(..), c

# Creation

@docs directory, file, currentWorkingDirectory
@docs directory, file


# POSIX
Expand All @@ -28,8 +28,6 @@ module Shikensu.Path exposing ( Path, Directory, File, Encapsulated, Kind(..), c

-}

import FileSystem
import Task exposing ( Task )


{-| Path type.
Expand Down Expand Up @@ -96,22 +94,6 @@ file =
Path File


{-| Get the absolute directory path of the current working directory.
-}
currentWorkingDirectory : FileSystem.Permission -> Task Never (Path Directory)
currentWorkingDirectory permission =
permission
|> FileSystem.currentWorkingDirectory
|> Task.map
(\a ->
if String.endsWith "/" a then
a
else
a ++ "/"
)
|> Task.map (fromPosix >> unwrap >> directory)



-- POSIX

Expand Down

0 comments on commit af89d2a

Please sign in to comment.