Skip to content

Commit

Permalink
v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Jan 5, 2024
1 parent 7048e95 commit 7115ec3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

## v1.1.1 - 5 January 2024
- Fix bug with double "/" from `get_files`

## v1.1.0 - 25 December 2023
- Added `set_permissions` and `set_permissions_octal` functions for setting
permissions on a file
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "simplifile"
version = "1.1.0"
version = "1.1.1"
description = "Basic file operations that work on all targets"

licences = ["Apache-2.0"]
Expand Down
11 changes: 10 additions & 1 deletion src/simplifile.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,16 @@ pub fn rename_directory(
///
pub fn get_files(in directory: String) -> Result(List(String), FileError) {
use contents <- result.try(read_directory(directory))
let paths = list.map(contents, fn(segment) { directory <> "/" <> segment })
let paths =
list.map(contents, fn(segment) {
case
directory
|> string.ends_with("/")
{
True -> directory <> segment
False -> directory <> "/" <> segment
}
})
let files = list.filter(paths, is_file)
case list.filter(paths, is_directory) {
[] -> Ok(files)
Expand Down
6 changes: 6 additions & 0 deletions test/simplifile_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,9 @@ pub fn permissions_octal_test() {
let assert Ok(Nil) = delete("./tmp/permissions/test2.sh")
let assert Ok(Nil) = delete("./tmp/permissions")
}

pub fn get_files_with_slash_test() {
let assert Ok(files) = get_files(in: "./test/")
files
|> should.equal(["./test/simplifile_test.gleam"])
}

0 comments on commit 7115ec3

Please sign in to comment.