mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: open repo secrets page in addition to README (#5684)
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
isAtCommand,
|
||||
isSlashCommand,
|
||||
copyToClipboard,
|
||||
getUrlOpenCommand,
|
||||
} from './commandUtils.js';
|
||||
|
||||
// Mock child_process
|
||||
@@ -342,4 +343,42 @@ describe('commandUtils', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUrlOpenCommand', () => {
|
||||
describe('on macOS (darwin)', () => {
|
||||
beforeEach(() => {
|
||||
mockProcess.platform = 'darwin';
|
||||
});
|
||||
it('should return open', () => {
|
||||
expect(getUrlOpenCommand()).toBe('open');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Windows (win32)', () => {
|
||||
beforeEach(() => {
|
||||
mockProcess.platform = 'win32';
|
||||
});
|
||||
it('should return start', () => {
|
||||
expect(getUrlOpenCommand()).toBe('start');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on Linux (linux)', () => {
|
||||
beforeEach(() => {
|
||||
mockProcess.platform = 'linux';
|
||||
});
|
||||
it('should return xdg-open', () => {
|
||||
expect(getUrlOpenCommand()).toBe('xdg-open');
|
||||
});
|
||||
});
|
||||
|
||||
describe('on unmatched OS', () => {
|
||||
beforeEach(() => {
|
||||
mockProcess.platform = 'unmatched';
|
||||
});
|
||||
it('should return xdg-open', () => {
|
||||
expect(getUrlOpenCommand()).toBe('xdg-open');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ export const isAtCommand = (query: string): boolean =>
|
||||
*/
|
||||
export const isSlashCommand = (query: string): boolean => query.startsWith('/');
|
||||
|
||||
//Copies a string snippet to the clipboard for different platforms
|
||||
// Copies a string snippet to the clipboard for different platforms
|
||||
export const copyToClipboard = async (text: string): Promise<void> => {
|
||||
const run = (cmd: string, args: string[]) =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
@@ -80,3 +80,27 @@ export const copyToClipboard = async (text: string): Promise<void> => {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
};
|
||||
|
||||
export const getUrlOpenCommand = (): string => {
|
||||
// --- Determine the OS-specific command to open URLs ---
|
||||
let openCmd: string;
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
openCmd = 'open';
|
||||
break;
|
||||
case 'win32':
|
||||
openCmd = 'start';
|
||||
break;
|
||||
case 'linux':
|
||||
openCmd = 'xdg-open';
|
||||
break;
|
||||
default:
|
||||
// Default to xdg-open, which appears to be supported for the less popular operating systems.
|
||||
openCmd = 'xdg-open';
|
||||
console.warn(
|
||||
`Unknown platform: ${process.platform}. Attempting to open URLs with: ${openCmd}.`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
return openCmd;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user