Skip to content

Commit ac850b6

Browse files
authored
Update for latest Gleam (#45)
This fixes deprecation warnings from Gleam v1.9.0.
1 parent a4c4c91 commit ac850b6

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: test
33
on:
44
push:
55
branches:
6-
- master
76
- main
87
pull_request:
98

@@ -14,10 +13,9 @@ jobs:
1413
- uses: actions/checkout@v3
1514
- uses: erlef/setup-beam@v1
1615
with:
17-
otp-version: "25.2"
18-
gleam-version: "1.2.0"
16+
otp-version: "27"
17+
gleam-version: "1.9.0"
1918
rebar3-version: "3"
2019
# elixir-version: "1.14.2"
21-
- run: gleam format --check src test
22-
- run: gleam deps download
2320
- run: gleam test
21+
- run: gleam format --check src test

gleam.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ description = "Basic file operations that work on all targets"
44

55
licences = ["Apache-2.0"]
66
repository = { type = "github", user = "bcpeinhardt", repo = "simplifile" }
7-
gleam = ">= 0.32.0"
7+
gleam = ">= 1.9.0"
88
# links = [{ title = "Website", href = "https://gleam.run" }]
99

1010
[javascript.deno]
1111
allow_all = true
1212

1313
[dependencies]
14-
gleam_stdlib = "~> 0.34 or ~> 1.0"
15-
filepath = "~> 1.0"
14+
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
15+
filepath = ">= 1.0.0 and < 2.0.0"
1616

1717
[dev-dependencies]
18-
gleeunit = "~> 1.0"
18+
gleeunit = ">= 1.0.0 and < 2.0.0"

manifest.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
6-
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
7-
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
5+
{ name = "filepath", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "65F51013BCF78A603AFFD7992EF1CC6ECA96C74038EB48887F656DE44DBC1902" },
6+
{ name = "gleam_stdlib", version = "0.58.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "091F2D2C4A3A4E2047986C47E2C2C9D728A4E068ABB31FDA17B0D347E6248467" },
7+
{ name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" },
88
]
99

1010
[requirements]
11-
filepath = { version = "~> 1.0"}
12-
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
13-
gleeunit = { version = "~> 1.0" }
11+
filepath = { version = ">= 1.0.0 and < 2.0.0" }
12+
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
13+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }

src/simplifile_js.mjs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export function readBits(filepath) {
2727
* @returns {Ok | GError}
2828
*/
2929
export function writeBits(filepath, contents) {
30-
return gleamResult(() => fs.writeFileSync(path.normalize(filepath), contents.buffer));
30+
return gleamResult(() =>
31+
fs.writeFileSync(path.normalize(filepath), contents.rawBuffer),
32+
);
3133
}
3234

3335
/**
@@ -38,7 +40,9 @@ export function writeBits(filepath, contents) {
3840
* @returns {Ok | GError}
3941
*/
4042
export function appendBits(filepath, contents) {
41-
return gleamResult(() => fs.appendFileSync(path.normalize(filepath), contents.buffer));
43+
return gleamResult(() =>
44+
fs.appendFileSync(path.normalize(filepath), contents.rawBuffer),
45+
);
4246
}
4347

4448
/**
@@ -163,7 +167,9 @@ export function readDirectory(filepath) {
163167
* @returns {Ok | GError}
164168
*/
165169
export function copyFile(srcpath, destpath) {
166-
return gleamResult(() => fs.copyFileSync(path.normalize(srcpath), path.normalize(destpath)));
170+
return gleamResult(() =>
171+
fs.copyFileSync(path.normalize(srcpath), path.normalize(destpath)),
172+
);
167173
}
168174

169175
/**
@@ -174,7 +180,9 @@ export function copyFile(srcpath, destpath) {
174180
* @returns {Ok | GError}
175181
*/
176182
export function renameFile(srcpath, destpath) {
177-
return gleamResult(() => fs.renameSync(path.normalize(srcpath), path.normalize(destpath)));
183+
return gleamResult(() =>
184+
fs.renameSync(path.normalize(srcpath), path.normalize(destpath)),
185+
);
178186
}
179187

180188
/**
@@ -204,8 +212,8 @@ export function currentDirectory() {
204212
*/
205213
export function fileInfo(filepath) {
206214
return gleamResult(() => {
207-
const stat = fs.statSync(path.normalize(filepath))
208-
return new FileInfo(stat)
215+
const stat = fs.statSync(path.normalize(filepath));
216+
return new FileInfo(stat);
209217
});
210218
}
211219

@@ -215,9 +223,9 @@ export function fileInfo(filepath) {
215223
*/
216224
export function linkInfo(filepath) {
217225
return gleamResult(() => {
218-
const stat = fs.lstatSync(path.normalize(filepath))
219-
return new FileInfo(stat)
220-
})
226+
const stat = fs.lstatSync(path.normalize(filepath));
227+
return new FileInfo(stat);
228+
});
221229
}
222230

223231
class FileInfo {

0 commit comments

Comments
 (0)