About S4Utils
A PowerShell Script Module for this bucket, which contains several functions to help building app manifests.
- New-ProfileModifier
- Add-ProfileContent
- Remove-ProfileContent
- Mount-ExternalRuntimeData
- Dismount-ExternalRuntimeData
- Import-PersistItem
- New-PersistItem
- Backup-PersistItem
Generate scripts which modifies PowerShell profile.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
Behavior |
String | ✓ | Type of scripts to generate, support ImportModule , RemoveModule in current version. |
PSModuleName |
String | ✓ | Name of PowerShell module, should be $manifest.psmodule.name in most situations. |
AppDir |
String | ✓ | Path of the app directory, should be $dir in most situations. |
BucketDir |
String | ✓ | Path of Scoop4kariiin bucket root directory. |
- See Windows-screenFetch manifest for example.
Add certain content to PowerShell profile. Scripts generated by New-ProfileModifier
will call this function.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
Content |
String | ✓ | Content to be added. |
- See Windows-screenFetch manifest for example.
Remove certain content from PowerShell profile. Scripts generated by New-ProfileModifier
will call this function.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
Content |
String | ✓ | Content to be removed. |
- See Windows-screenFetch manifest for example.
Mount external runtime data.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
Source |
String | ✓ | Path of source folder in scoop persist directory. |
Target |
String | ✗ | The actual path which app uses to access the runtime data. |
AppData |
Switch | ✗ | Conveniently mount folder in $env:APPDATA by the name of source folder. Value of $Target will be overwritten. |
- Either
Target
orAppData
should be specified. - See link-plus manifest for example.
Unmount external runtime data.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
Target |
String | ✓ | Path or name of runtime folder mounted by scoop. |
AppData |
Switch | ✗ | Conveniently dismount folder in $env:APPDATA with folder name in Target parameter. Value of $Target will be overwritten. |
- See link-plus manifest for example.
Import files persisted by other app.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
PersistDir |
String | ✓ | Path of persist directory. Use $persist_dir here. |
SourceApp |
String | ✓ | Name of source app to import from. |
ConflictAction |
String | ✗ | Actions when item conflicts. Use Skip to skip entire importing process.Use Mix to skip conflict items in target directory and import non-conflict ones from source directory.Use Overwrite to force import items from source directory and keep non-conflict ones in target directory.Use ReplaceDir to totally replace entire directory. |
Select |
String | ✗ | Specific items to import. Use , to separate multiple values. |
Sync |
Switch | ✗ | Create junction instead of copying files. |
Backup |
Switch | ✗ | Rename original item instead of removing it. |
- See Snipaste2 manifest for example.
Create items in persist directory.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
PersistDir |
String | ✓ | Path of persist directory. Use $persist_dir here. |
Name |
String | ✓ | Name of item to create. Use , to separate multiple values. |
Type |
String | ✓ | Type of item to create. |
Content |
String | ✗ | Initial content of file, use with parameter -Type File . |
Force |
Switch | ✗ | Force overwrite if target exists. |
Backup |
Switch | ✗ | Rename original item instead of removing it, use with parameter -Force . |
- See Snipaste2 manifest for example.
Backup items to persist directory.
Parameters | Type | Mandatory | Descriptions |
---|---|---|---|
AppDir |
String | ✓ | Path of app directory. Use $dir here. |
PersistDir |
String | ✓ | Path of persist directory. Use $persist_dir here. |
Name |
String | ✓ | Name of item to backup. Use , to separate multiple values. |
- See Snipaste2 manifest for example.
# Get the path of S4Utils.
$S4UtilsPath = Find-BucketDirectory -Root -Name $bucket | Join-Path -ChildPath "scripts\S4Utils.psm1"
# Find-BucketDirectory is a function added by scoop which helps generating bucket path.
# For "Name" parameter, use "$bucket" in installation-ish processes, use "$install.bucket" in uninstallation-ish processes.
# Import and use if exists.
if (Test-Path $S4UtilsPath) {
Unblock-File $S4UtilsPath # Unblock file to avoid permission issues.
Import-Module $S4UtilsPath
... # Call functions according to demands.
Remove-Module -Name S4Utils -ErrorAction SilentlyContinue # Remove it to avoid conflicts.
}