decharge-scout 1.1.0 ā 1.2.1
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/index.js +24 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -174,16 +174,32 @@ async function main(options) {
|
|
|
174
174
|
const detectedLocation = await getLocation();
|
|
175
175
|
locationSpinner.succeed(chalk.green(`š Detected Location: ${detectedLocation}`));
|
|
176
176
|
|
|
177
|
-
// Ask user to confirm or override
|
|
177
|
+
// Ask user to confirm or override (with timeout)
|
|
178
178
|
console.log(chalk.blue('\nYou can use this location or enter a custom one.'));
|
|
179
|
-
|
|
179
|
+
console.log(chalk.gray('(Press Enter to use detected location, or type custom location)'));
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
try {
|
|
182
|
+
// Create a promise that auto-resolves after 10 seconds
|
|
183
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
console.log(chalk.yellow('\nā±ļø No input received, using detected location...'));
|
|
186
|
+
resolve('');
|
|
187
|
+
}, 10000);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const questionPromise = question('Enter custom location (or press Enter): ');
|
|
191
|
+
|
|
192
|
+
const customLocation = await Promise.race([questionPromise, timeoutPromise]);
|
|
193
|
+
location = customLocation.trim() || detectedLocation;
|
|
194
|
+
|
|
195
|
+
if (customLocation.trim()) {
|
|
196
|
+
console.log(chalk.green(`ā Using custom location: ${location}`));
|
|
197
|
+
} else {
|
|
198
|
+
console.log(chalk.green(`ā Using detected location: ${location}`));
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.log(chalk.yellow(`\nā ļø Prompt error, using detected location: ${detectedLocation}`));
|
|
202
|
+
location = detectedLocation;
|
|
187
203
|
}
|
|
188
204
|
} else {
|
|
189
205
|
console.log(chalk.green(`š Location: ${location}`));
|