Skip to content

Commit d6025f5

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 d6025f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/clib-install.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,14 @@ 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+
pkg->repo = malloc(sizeof(version_char - slug) + 1);
313+
memcpy(pkg->repo, slug, sizeof(version_char - slug) + 1);
314+
} else {
315+
pkg->repo = strdup(slug);
316+
}
310317
}
311318

312319
if (!opts.nosave) {

0 commit comments

Comments
 (0)