coursecode 0.1.5 → 0.1.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/lib/cloud.js +8 -1
- package/package.json +1 -1
package/lib/cloud.js
CHANGED
|
@@ -319,13 +319,20 @@ async function runLoginFlow() {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
|
-
* Ensure the user is authenticated. Auto-triggers login if
|
|
322
|
+
* Ensure the user is authenticated. Auto-triggers login if interactive.
|
|
323
|
+
* In non-interactive environments, exits with an error message.
|
|
323
324
|
* @returns {Promise<string>} The API token
|
|
324
325
|
*/
|
|
325
326
|
export async function ensureAuthenticated() {
|
|
326
327
|
const creds = readCredentials();
|
|
327
328
|
if (creds?.token) return creds.token;
|
|
328
329
|
|
|
330
|
+
// Non-interactive: can't launch browser login — exit with clear error
|
|
331
|
+
if (!process.stdin.isTTY) {
|
|
332
|
+
console.error('\n❌ No Cloud credentials found. Run `coursecode login` first.\n');
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
|
|
329
336
|
console.log('\n No Cloud credentials found. Launching login...');
|
|
330
337
|
return runLoginFlow();
|
|
331
338
|
}
|