This commit addresses an issue in the privacy.sexy desktop application
where scripts executed as administrator on Windows were running in the
background. This was observed in environments like Windows Pro VMs on
Azure, where operations typically run with administrative privileges.
Previously, the application used the `"$path"` shell command to execute
scripts. This mechanism failed to activate the logic for requesting
admin privileges if the app itself was running as an administrator.
To resolve this, the script execution process has been modified to
explicitly ask for administrator privileges using the `VerbAs` method.
This ensures that the script always runs in a new `cmd.exe` window,
enhancing visibility and user interaction.
Other supporting changes:
- Rename the generated script file from `run-{timestamp}-{extension}` er
to `{timestamp}-privacy-script-{extension}` for clearer identification
and better file sorting.
- Refactor `ScriptFileCreator` to parameterize file extension and
script name.
- Rename `OsTimestampedFilenameGenerator` to
`TimestampedFilenameGenerator` to better reflect its new and more
scoped functionality after refactoring mentioned abvoe.
- Remove `setAppName()` due to ineffective behavior in Windows.
- Update `SECURITY.md` to highlight that the app doesn't require admin
rights for standard operations.
- Add `.editorconfig` settings for PowerShell scripts.
- Add a integration test for script execution logic. Improve environment
detection for more reliable test execution.
- Disable application logging during unit/integration tests to keep test
outputs clean and focused.
19 lines
816 B
TypeScript
19 lines
816 B
TypeScript
/**
|
|
* Asserts that the provided value is neither null nor undefined.
|
|
*
|
|
* This function is a more explicit alternative to `expect(value).to.exist` in test cases.
|
|
* It is particularly useful in situations where TypeScript's control flow analysis
|
|
* does not recognize standard assertions, ensuring that `value` is treated as
|
|
* non-nullable in the subsequent code. This can prevent potential type errors
|
|
* and enhance code safety and clarity.
|
|
*/
|
|
export function expectExists<T>(value: T, errorMessage?: string): asserts value is NonNullable<T> {
|
|
if (value === null || value === undefined) {
|
|
throw new Error([
|
|
'Assertion failed: expected value is either null or undefined.',
|
|
'Expected a non-null and non-undefined value.',
|
|
...(errorMessage ? [errorMessage] : []),
|
|
].join('\n'));
|
|
}
|
|
}
|