Skip to content

Commit 7ba290d

Browse files
committed
fix(clib-install): check if version was specified when installing.
the names was used when writing the dependencies which causes this $ clib install [email protected] is written on json as "[email protected]": "0.1.0"
1 parent d987893 commit 7ba290d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/clib-install.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,15 @@ static int install_package(const char *slug) {
306306
}
307307

308308
if (0 == pkg->repo || 0 != strcmp(slug, pkg->repo)) {
309-
pkg->repo = strdup(slug);
309+
char* version_char = NULL;
310+
// NOTE: check if version was specified
311+
if ((version_char = strchr(slug, '@')) != NULL) {
312+
size_t length = version_char - slug;
313+
pkg->repo = malloc(sizeof(char) * length);
314+
memcpy(pkg->repo, slug, length);
315+
} else {
316+
pkg->repo = strdup(slug);
317+
}
310318
}
311319

312320
if (!opts.nosave) {

0 commit comments

Comments
 (0)