Skip to content

Commit bb1eeba

Browse files
committed
remove extra shared functions & loader
1 parent ace9aad commit bb1eeba

3 files changed

Lines changed: 91 additions & 17 deletions

File tree

Bookmarks/Bookmarks.psd1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#
1+
#
22
# Module manifest for module 'Bookmarks'
33
#
44
# Generated by: Dmitry Stadub
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.0'
15+
ModuleVersion = '2.1.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -69,7 +69,7 @@ Full documentation at the Github: https://github.com/stadub/PowershellScripts/tr
6969

7070
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
7171
#NestedModules = @('Aliases.ps1','Functions.ps1')
72-
ModuleToProcess = "Bookmarks.psm1"
72+
RootModule = "Bookmarks.psm1"
7373

7474
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
7575
FunctionsToExport = @('*')
@@ -115,6 +115,7 @@ PrivateData = @{
115115
Move initation logic to Loader.psm1
116116
Change test environment to StrictMode=Latest
117117
Update icon.
118+
Remove extra hared functions
118119
'
119120

120121
} # End of PSData hashtable

Bookmarks/Bookmarks.psm1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
if($ModuleDevelopment){
2-
. $PSScriptRoot\..\Shared-Functions\ModuleLoader.ps1 "$PSScriptRoot"
3-
}
4-
else {
5-
if( -not $SharedLocal -or -not (Test-Path $SharedLocal) ){
6-
throw "Shared functions folder doesn't exist.
7-
Looks like module typing to start in Develoment mode.
8-
To start Development mode set flag: `$ModuleDevelopment=`$true
9-
Also you can set `$DebugPreference=`"Continue`" to getmore detalied strack trace
10-
Or set `$NoExport=`$True to disable `Export-ModuleMember` functions
11-
"
12-
}
13-
. $PSScriptRoot\Shared\ModuleLoader.ps1 "$PSScriptRoot"
14-
}
1+
. $PSScriptRoot\Functions.ps1
2+
. $PSScriptRoot\Shared-Functions.ps1
153

4+
5+
_Initalize
6+
7+
Export-ModuleMember -Function Add-PSBookmark
8+
Export-ModuleMember -Function Remove-PSBookmark
9+
Export-ModuleMember -Function Remove-AllPSBookmarks
10+
Export-ModuleMember -Function Open-PSBookmark
11+
Export-ModuleMember -Function Restore-PSBookmarks
12+
Export-ModuleMember -Function Save-PSBookmarks
13+
Export-ModuleMember -Function Get-PSBookmarks
14+
Export-ModuleMember -Function Update-PSBookmark
15+
. $PSScriptRoot\Aliases.ps1

Bookmarks/Shared-Functions.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
3+
function CreateFolderIfNotExist {
4+
param ([string]$Folder)
5+
if( Test-Path $Folder -PathType Leaf){
6+
Write-Error "The destanation path ${Folder} is file."
7+
}
8+
9+
if ( ! (Test-Path $Folder -PathType Container )) {
10+
New-Item -Path $Folder -ItemType 'Directory'
11+
}
12+
}
13+
14+
15+
function Test-Empty {
16+
param (
17+
[Parameter(Position = 0)]
18+
[string]$string
19+
)
20+
return [string]::IsNullOrWhitespace($string)
21+
}
22+
23+
function Get-ProfileDataFile {
24+
param (
25+
[string]$file,
26+
[string]$moduleName = $null
27+
)
28+
return Join-Path (Get-ProfileDir $moduleName) $file
29+
30+
}
31+
function Get-ProfileDir {
32+
param (
33+
[string]$moduleName = $null
34+
)
35+
36+
$profileDir = $ENV:AppData
37+
38+
if( Test-Empty $moduleName ){
39+
40+
if ( $script:MyInvocation.MyCommand.Name.EndsWith('.psm1') ){
41+
$moduleName = $script:MyInvocation.MyCommand.Name
42+
}
43+
44+
if ( $script:MyInvocation.MyCommand.Name.EndsWith('.ps1') ){
45+
$modulePath = Split-Path -Path $script:MyInvocation.MyCommand.Path
46+
$moduleName = Split-Path -Path $modulePath -Leaf
47+
}
48+
}
49+
50+
if( Test-Empty $moduleName ){
51+
throw "Unable to read module name."
52+
}
53+
54+
$scriptProfile = Combine-Path $profileDir '.ps1' 'ScriptData' $moduleName
55+
if ( ! (Test-Path $scriptProfile -PathType Container )) {
56+
New-Item -Path $scriptProfile -ItemType 'Directory'
57+
}
58+
return $scriptProfile
59+
}
60+
61+
62+
function Combine-Path {
63+
param (
64+
[string]$baseDir,
65+
[string]$path
66+
)
67+
$allArgs = $PsBoundParameters.Values + $args
68+
69+
[IO.Path]::Combine([string[]]$allArgs)
70+
}
71+
72+
$_sharedLoaded = $true
73+

0 commit comments

Comments
 (0)