@shreyash1601/oopsify 1.0.5 → 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.
- package/bin/index.js +25 -2
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -6,6 +6,23 @@ const sound = require('sound-play');
|
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const isWindows = process.platform === 'win32';
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
function getPowerShellCommand() {
|
|
13
|
+
try {
|
|
14
|
+
execSync('powershell -Command "echo test"', { stdio: 'ignore' });
|
|
15
|
+
return 'powershell';
|
|
16
|
+
} catch {
|
|
17
|
+
try {
|
|
18
|
+
execSync('pwsh -Command "echo test"', { stdio: 'ignore' });
|
|
19
|
+
return 'pwsh';
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
(async () => {
|
|
10
27
|
// 👉 ESM imports
|
|
11
28
|
const chalkImport = await import('chalk');
|
|
@@ -22,10 +39,16 @@ if (command === 'setup') {
|
|
|
22
39
|
const { execSync } = require('child_process');
|
|
23
40
|
|
|
24
41
|
if (isWindows) {
|
|
42
|
+
const shell = getPowerShellCommand();
|
|
43
|
+
|
|
44
|
+
if (!shell) {
|
|
45
|
+
console.error('❌ PowerShell not found on this system');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
25
49
|
try {
|
|
26
|
-
// 👉 Get actual PowerShell profile path
|
|
27
50
|
const profilePath = execSync(
|
|
28
|
-
|
|
51
|
+
`${shell} -NoProfile -Command "$PROFILE"`,
|
|
29
52
|
{ encoding: 'utf-8' }
|
|
30
53
|
).trim();
|
|
31
54
|
|