Skip to content

Commit 217bc10

Browse files
committed
fix stuff in packages
1 parent d633afa commit 217bc10

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

lang/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ Cargo.lock
2121
#.idea/
2222

2323
# Modu
24-
.modu/
24+
.modu/
25+
26+
# Other
27+
tmp

lang/examples/library/project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "test"
3-
version = "2.0.5"
3+
version = "2.0.7"
44
description = "A package im using to test the package system, this is not a package for units tests or shit"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn equals(a,b) {
2+
if a == b {
3+
return true;
4+
}
5+
6+
return false;
7+
}

lang/src/cli/install.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,30 @@ fn install_package(name: &str, version: &str) -> Result<serde_json::Value, Strin
3737
let mut file = archive.by_index(i).unwrap();
3838
let path = ".modu/packages/".to_string() + name + "/" + file.name();
3939

40-
if file.name().ends_with("/") {
41-
std::fs::create_dir_all(path).unwrap();
40+
if file.name().contains("/") || file.name().contains("\\") {
41+
if file.name().contains("/") {
42+
let mut path = path.split("/").collect::<Vec<&str>>();
43+
path.pop();
44+
45+
std::fs::create_dir_all(path.join("/")).unwrap();
46+
} else {
47+
let mut path = path.split("\\").collect::<Vec<&str>>();
48+
path.pop();
49+
50+
std::fs::create_dir_all(path.join("\\")).unwrap();
51+
}
52+
53+
54+
let mut out = std::fs::File::create(".modu/packages/".to_string() + name + "/" + file.name()).unwrap();
55+
std::io::copy(&mut file, &mut out).unwrap();
56+
4257
} else {
58+
#[cfg(windows)]
59+
let path = path.replace("/", "\\");
60+
61+
#[cfg(not(windows))]
62+
let path = path.replace("\\", "/");
63+
4364
let mut out = std::fs::File::create(path).unwrap();
4465
std::io::copy(&mut file, &mut out).unwrap();
4566
}

lang/src/cli/publish.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use toml;
44
use zip;
55
use serde_json::json;
66

7-
static BLOCKLIST: [&str; 3] = [".git", ".gitignore", ".modu"];
7+
static BLOCKLIST: [&str; 4] = [".git", ".gitignore", ".modu", ".github"];
88

99
fn read_dir(dir: &std::path::Path, archive: &mut zip::ZipWriter<std::fs::File>) {
1010
for entry in std::fs::read_dir(dir).unwrap() {
@@ -14,7 +14,7 @@ fn read_dir(dir: &std::path::Path, archive: &mut zip::ZipWriter<std::fs::File>)
1414
let mut do_break = false;
1515

1616
for item in BLOCKLIST.iter() {
17-
if path.to_str().unwrap().replace("./", "") == *item {
17+
if path.to_str().unwrap().replace("\\", "/") == format!("./{}", item) {
1818
println!("Ignoring {}", path.to_str().unwrap());
1919
do_break = true;
2020
}
@@ -33,7 +33,7 @@ fn read_dir(dir: &std::path::Path, archive: &mut zip::ZipWriter<std::fs::File>)
3333
file.read_to_string(&mut gitignore_content).unwrap();
3434

3535
for line in gitignore_content.lines() {
36-
if path.to_str().unwrap().replace("./", "") == line {
36+
if path.to_str().unwrap().replace("\\", "/") == format!("./{}", line) {
3737
println!("Ignoring {}", path.to_str().unwrap());
3838
do_break = true;
3939
}

0 commit comments

Comments
 (0)