Skip to content

Commit 6f66e0b

Browse files
author
James Brundage
committed
feat: Exporting $RoughDraft and mounting module ( Fixes #201, Fixes #202, Fixes #270 )
1 parent 7e12979 commit 6f66e0b

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

Container.start.ps1

+10-13
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@ using namespace 'ghcr.io/startautomating/roughdraft'
2929
param()
3030

3131
$env:IN_CONTAINER = $true
32-
33-
$global:ContainerInfo = [Ordered]@{
34-
MountedPaths = if (Test-Path '/proc/mounts') {
35-
@(
36-
(Select-String "\S+\s(?<p>\S+).+rw?,.+symlinkroot=/mnt/host" "/proc/mounts").Matches.Groups |
37-
Where-Object Name -eq p |
38-
Get-Item -path { $_.Value }
39-
)
40-
}
41-
}
42-
$global:ContainerInfo.MountedFiles = $global:ContainerInfo.MountedPaths | Get-ChildItem -File -Recurse
32+
$PSStyle.OutputRendering = 'Ansi'
33+
34+
$mountedDrives = @(if (Test-Path '/proc/mounts') {
35+
(Select-String "\S+\s(?<p>\S+).+rw?,.+symlinkroot=/mnt/host" "/proc/mounts").Matches.Groups |
36+
Where-Object Name -eq p |
37+
Get-Item -path { $_.Value } |
38+
Mount-RoughDraft
39+
})
4340

4441
if ($global:ContainerInfo.MountedPaths) {
45-
"Mounted $($global:ContainerInfo.MountedFiles.Length) files from $($global:ContainerInfo.MountedPaths.Length) paths:" | Out-Host
46-
$global:ContainerInfo.MountedPaths | Out-Host
42+
"Mounted $($mountedDrives.Length) drives:" | Out-Host
43+
$mountedDrives | Out-Host
4744
}
4845

4946
if ($args) {

RoughDraft.ps.psm1

+17
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,21 @@ if ($partsDirectory) { # If we have parts directory
3131
}
3232
}
3333
#endregion Import Parts
34+
35+
#region Export Myself
36+
37+
# Get my module
38+
$MyModule = $MyInvocation.MyCommand.ScriptBlock.Module
39+
# and decorate it with my name (this enables extensibility)
40+
$MyModule.pstypenames.insert(0,$MyModule.Name)
41+
# and set a variable with my name that points to me.
42+
$ExecutionContext.SessionState.PSVariable.Set($MyModule.Name, $myModule)
43+
#endregion Export Myself
44+
45+
#region Mount Myself
46+
# Mount myself as a drive
47+
$newDriveSplat = @{PSProvider='FileSystem';ErrorAction='Ignore';Scope='Global'}
48+
New-PSDrive -Name $MyModule.Name -Root ($MyModule | Split-Path) @newDriveSplat
49+
#endregion Mount Myself
50+
3451
Export-ModuleMember -Function *-* -Alias *

0 commit comments

Comments
 (0)