Skip to content

Commit

Permalink
Add type annotation to main in new project template
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Mar 10, 2025
1 parent 2bbe1dc commit d9ec3ec
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler-cli/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ gleam add {project_name}@1
```gleam
import {project_name}
pub fn main() {{
pub fn main() -> Nil {{
// TODO: An example of the project in use
}}
```
Expand Down Expand Up @@ -124,7 +124,7 @@ erl_crash.dump
Self::SrcModule => Some(format!(
r#"import gleam/io
pub fn main() {{
pub fn main() -> Nil {{
io.println("Hello from {project_name}!")
}}
"#,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gleam add my_project@1
```gleam
import my_project
pub fn main() {
pub fn main() -> Nil {
// TODO: An example of the project in use
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: compiler-cli/src/new/tests.rs
expression: "crate::fs::read(Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect(\"Non Utf8 Path\"),).unwrap()"
---
import gleam/io

pub fn main() -> Nil {
io.println("Hello from my_project!")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: compiler-cli/src/new/tests.rs
expression: "crate::fs::read(Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect(\"Non Utf8 Path\"),).unwrap()"
---
import gleeunit
import gleeunit/should

pub fn main() {
gleeunit.main()
}

// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(1)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gleam add my_project@1
```gleam
import my_project
pub fn main() {
pub fn main() -> Nil {
// TODO: An example of the project in use
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: compiler-cli/src/new/tests.rs
expression: "crate::fs::read(Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect(\"Non Utf8 Path\"),).unwrap()"
---
import gleam/io

pub fn main() -> Nil {
io.println("Hello from my_project!")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: compiler-cli/src/new/tests.rs
expression: "crate::fs::read(Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect(\"Non Utf8 Path\"),).unwrap()"
---
import gleeunit
import gleeunit/should

pub fn main() {
gleeunit.main()
}

// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(1)
}
26 changes: 24 additions & 2 deletions compiler-cli/src/new/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ fn new_with_default_template() {
.unwrap();
creator.run().unwrap();

insta::glob!(path, "my_project/*.*", |file_path| {
insta::glob!(&path, "my_project/*.*", |file_path| {
if !file_path.is_dir() {
insta::assert_snapshot!(
crate::fs::read(
Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect("Non Utf8 Path"),
)
.unwrap()
);
}
});

insta::glob!(&path, "my_project/**/*.gleam", |file_path| {
if !file_path.is_dir() {
insta::assert_snapshot!(
crate::fs::read(
Expand Down Expand Up @@ -81,7 +92,18 @@ fn new_with_javascript_template() {
.unwrap();
creator.run().unwrap();

insta::glob!(path, "my_project/*.*", |file_path| {
insta::glob!(&path, "my_project/*.*", |file_path| {
if !file_path.is_dir() {
insta::assert_snapshot!(
crate::fs::read(
Utf8PathBuf::from_path_buf(file_path.to_path_buf()).expect("Non Utf8 Path"),
)
.unwrap()
);
}
});

insta::glob!(&path, "my_project/**/*.gleam", |file_path| {
if !file_path.is_dir() {
insta::assert_snapshot!(
crate::fs::read(
Expand Down

0 comments on commit d9ec3ec

Please sign in to comment.