summaryrefslogtreecommitdiffstats
path: root/src/package
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:23:35 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:26:16 +0100
commit83b3b97fee854e19c63999e4daadf802784a1499 (patch)
treeaadb169bde50d4497110a7f8989fde755d255c92 /src/package
parent5ff10cdad822300a04ffe3cb2482e20c37d7c2bd (diff)
Implement shebang overwriting
This patch implements the shebang overwriting functionality that was in a TODO note. It adds a `Shebang` type for it, which is a String wrapper. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/package')
-rw-r--r--src/package/script.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/package/script.rs b/src/package/script.rs
index caa6976..968f364 100644
--- a/src/package/script.rs
+++ b/src/package/script.rs
@@ -12,6 +12,15 @@ use crate::phase::PhaseName;
#[serde(transparent)]
pub struct Script(String);
+#[derive(Clone, Debug)]
+pub struct Shebang(String);
+
+impl From<String> for Shebang {
+ fn from(s: String) -> Self {
+ Shebang(s)
+ }
+}
+
impl AsRef<str> for Script {
fn as_ref(&self) -> &str {
self.0.as_ref()
@@ -19,19 +28,18 @@ impl AsRef<str> for Script {
}
pub struct ScriptBuilder<'a> {
- shebang : &'a String,
+ shebang: &'a Shebang,
}
impl<'a> ScriptBuilder<'a> {
- // TODO: Use handlebars and templating instead of hardcoding
- pub fn new(shebang: &'a String) -> Self {
+ pub fn new(shebang: &'a Shebang) -> Self {
ScriptBuilder {
shebang,
}
}
pub fn build(self, package: &Package, phaseorder: &Vec<PhaseName>, strict_mode: bool) -> Result<Script> {
- let mut script = format!("{shebang}\n", shebang = self.shebang);
+ let mut script = format!("{shebang}\n", shebang = self.shebang.0);
for name in phaseorder {
match package.phases().get(name) {