Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for package versions #43

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 11 additions & 2 deletions nupm/install.nu
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def install-scripts [
#
# Input: Modules taken from 'package.nuon'
def install-modules [
package: record # The content of the package
pkg_dir: path # Package directory
modules_dir: path # Target directory where to install
--force(-f): bool # Overwrite already installed modules
Expand All @@ -91,6 +92,14 @@ def install-modules [

log debug $"installing module `($src_path)` to `($modules_dir)`"
cp -r $src_path $modules_dir

let version = $"($package.name)@($package.version)"
ls ($modules_dir | path join "**/*")
| where type == file
| get name
| each {|it|
open $it | str replace --all "{{ NUPM_VERSION }}" $version | save --force $it
}
}

null
Expand Down Expand Up @@ -118,7 +127,7 @@ def install-path [
[]
}
| append ($package.modules? | default [])
| install-modules $pkg_dir (module-dir --ensure) --force $force
| install-modules $package $pkg_dir (module-dir --ensure) --force $force

$package.scripts?
| default []
Expand All @@ -137,7 +146,7 @@ def install-path [

$package.modules?
| default []
| install-modules $pkg_dir (module-dir --ensure) --force $force
| install-modules $package $pkg_dir (module-dir --ensure) --force $force
},
"custom" => {
let build_file = $pkg_dir | path join "build.nu"
Expand Down
3 changes: 3 additions & 0 deletions nupm/version.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export def main []: nothing -> string {
"{{ NUPM_VERSION }}"
}