Skip to content
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
2 changes: 1 addition & 1 deletion nupm/install.nu
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def download-pkg [
throw-error $'Error cloning repository ($pkg.info.url)'
}
(
assert (not ($pkg_dir | path exists))
assert ($pkg_dir | path exists)
$'Package path ($pkg.path) does not exist in cloned repository'
--error-label={text: "path_missing", span:(metadata $pkg_dir | get span)}
)
Expand Down
22 changes: 20 additions & 2 deletions tests/mod.nu
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std assert
use std/assert

use ../nupm/utils/dirs.nu
use ../nupm/utils/dirs.nu [ tmp-dir REGISTRY_FILENAME ]
use ../nupm

const DIRNAME = path self .
const TEST_REGISTRY_PATH = ([tests packages registry $REGISTRY_FILENAME] | path join)


Expand Down Expand Up @@ -90,6 +91,17 @@ export def install-from-local-registry [] {
nupm install spam_script
check-file-content 0.2.0
}

with-test-env {
$env.NUPM_GIT_CLONE_ARGS = [
"--reference-if-able"
($DIRNAME | path join ".." | path expand)
"--revision"
(git rev-parse HEAD)
]

nupm install spam_git
}
}

export def install-with-version [] {
Expand Down Expand Up @@ -129,7 +141,7 @@ export def install-package-not-found [] {

export def search-registry [] {
with-test-env {
assert ((nupm search spam | length) == 4)
assert ((nupm search spam | length) == 5)
}
}

Expand Down Expand Up @@ -177,6 +189,12 @@ export def generate-local-registry [] {
nupm publish $tmp_reg_file --local --save --path (".." | path join $pkg)
}

do {
let pkg = "spam_git"
cd ([tests packages $pkg] | path join)
nupm publish $tmp_reg_file --git --save --info {url: "https://github.com/nushell/nupm.git" revision: "main"} --path $"tests/packages/($pkg)"
}

let actual = open $tmp_reg_file | to nuon
let expected = open $reg_file | to nuon

Expand Down
1 change: 1 addition & 0 deletions tests/packages/registry/registry.nuon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[name, path, hash];

[spam_custom, spam_custom.nuon, "md5-7b3a5119d1af5a025dae32bcfc7cab96"],
[spam_git, spam_git.nuon, "md5-6d79981218772b4b130cb5d48b15a70f"],
[spam_module, spam_module.nuon, "md5-618c7c8ed97b423f111790d97bcd8486"],
[spam_script, spam_script.nuon, "md5-ce1b060a68ebb42291e364b5daa6d47a"],
]
1 change: 1 addition & 0 deletions tests/packages/registry/spam_git.nuon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[name, version, path, type, info]; [spam_git, "0.1.0", tests/packages/spam_git, git, {url: "https://github.com/nushell/nupm.git", revision: main}]]
6 changes: 6 additions & 0 deletions tests/packages/spam_git/nupm.nuon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
name: spam_git,
type: module,
version: "0.1.0"
scripts: [script.nu]
}
1 change: 1 addition & 0 deletions tests/packages/spam_git/script.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print 'git'
3 changes: 3 additions & 0 deletions tests/packages/spam_git/spam_git/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export def main [] {
"Hello Git!"
}
Loading