Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

feat(projecttype): default to webpack #144

Merged
merged 5 commits into from
May 25, 2019
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
4 changes: 2 additions & 2 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn generate(

let args = ["generate", "--git", template, "--name", name, "--force"];

let pt = pt.unwrap_or(project_type(template));
let pt = pt.unwrap_or_else(|| project_type(template));
let command = command(name, binary_path, &args, &pt);
let command_name = format!("{:?}", command);

Expand Down Expand Up @@ -51,5 +51,5 @@ fn project_type(template: &str) -> ProjectType {
if template.contains("rust") {
return ProjectType::Rust;
}
ProjectType::JavaScript
ProjectType::default()
}
14 changes: 6 additions & 8 deletions src/commands/publish/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ impl Package {
failure::bail!(
"The `main` key in your `package.json` file is required; please specified the entrypoint of your Worker.",
)
} else if !Path::new(&self.main).exists() {
failure::bail!(
"The entrypoint of your Worker ({}) could not be found.",
self.main
)
} else {
if !Path::new(&self.main).exists() {
failure::bail!(
"The entrypoint of your Worker ({}) could not be found.",
self.main
)
} else {
Ok(self.main.clone())
}
Ok(self.main.clone())
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::redundant_closure)]

use std::env;
use std::str::FromStr;

Expand Down
6 changes: 6 additions & 0 deletions src/settings/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub enum ProjectType {
Webpack,
}

impl Default for ProjectType {
fn default() -> Self {
ProjectType::Webpack
}
}

impl fmt::Display for ProjectType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let printable = match *self {
Expand Down
4 changes: 1 addition & 3 deletions src/wranglerjs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,11 @@ fn create_metadata(bundle: &Bundle) -> String {
)
.to_string()
} else {
format!(
r#"
r#"
{{
"body_part": "script"
}}
"#
)
.to_string()
}
}
Expand Down