@fredlackey/devutils 0.0.4 → 0.0.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.
package/package.json
CHANGED
|
@@ -577,8 +577,20 @@ async function install_windows() {
|
|
|
577
577
|
return;
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
// winget failed
|
|
581
|
-
|
|
580
|
+
// winget failed - check if it's a "already installed" scenario
|
|
581
|
+
// winget returns non-zero even when the app is already installed
|
|
582
|
+
if (result.output && result.output.includes('already installed')) {
|
|
583
|
+
console.log('Google Chrome is already installed.');
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// winget failed, log the error and try Chocolatey as fallback
|
|
588
|
+
console.log('winget installation failed:');
|
|
589
|
+
if (result.output) {
|
|
590
|
+
console.log(result.output);
|
|
591
|
+
}
|
|
592
|
+
console.log('');
|
|
593
|
+
console.log('Trying Chocolatey as fallback...');
|
|
582
594
|
}
|
|
583
595
|
|
|
584
596
|
// Try Chocolatey if available
|
|
@@ -124,11 +124,32 @@ function which(executable) {
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Checks if a command is available in PATH
|
|
127
|
+
*
|
|
128
|
+
* On Windows, this also handles App Execution Aliases (used by winget, etc.)
|
|
129
|
+
* which are special reparse points that don't appear as regular files to
|
|
130
|
+
* fs.statSync().isFile(). We fall back to using the 'where' command for these.
|
|
131
|
+
*
|
|
127
132
|
* @param {string} command - The command to check
|
|
128
133
|
* @returns {boolean}
|
|
129
134
|
*/
|
|
130
135
|
function commandExists(command) {
|
|
131
|
-
|
|
136
|
+
// First try the file-based check (works for regular executables)
|
|
137
|
+
if (which(command) !== null) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// On Windows, App Execution Aliases (like winget) don't appear as regular
|
|
142
|
+
// files to fs.statSync(). Use 'where' command as a fallback.
|
|
143
|
+
if (process.platform === 'win32') {
|
|
144
|
+
try {
|
|
145
|
+
cpExecSync(`where ${command}`, { stdio: 'ignore' });
|
|
146
|
+
return true;
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return false;
|
|
132
153
|
}
|
|
133
154
|
|
|
134
155
|
/**
|