Skip to content

Latest commit

 

History

History
150 lines (101 loc) · 5.52 KB

README.md

File metadata and controls

150 lines (101 loc) · 5.52 KB

About S4Utils

A PowerShell Script Module for this bucket, which contains several functions to help building app manifests.

Functions


New-ProfileModifier

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.

Add-ProfileContent

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.

Remove-ProfileContent

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.

Mount-ExternalRuntimeData

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.

Dismount-ExternalRuntimeData

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.

Import-PersistItem

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.

New-PersistItem

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.

Backup-PersistItem

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.

Use in manifests

# 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.
}