2025-08-06 02:01:01 +09:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-25 22:11:27 +02:00
|
|
|
import * as path from 'node:path';
|
2026-01-06 20:09:39 -08:00
|
|
|
import { homedir } from '@google/gemini-cli-core';
|
2025-08-06 02:01:01 +09:00
|
|
|
|
|
|
|
|
export function resolvePath(p: string): string {
|
|
|
|
|
if (!p) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
let expandedPath = p;
|
|
|
|
|
if (p.toLowerCase().startsWith('%userprofile%')) {
|
2026-01-06 20:09:39 -08:00
|
|
|
expandedPath = homedir() + p.substring('%userprofile%'.length);
|
2025-08-06 02:01:01 +09:00
|
|
|
} else if (p === '~' || p.startsWith('~/')) {
|
2026-01-06 20:09:39 -08:00
|
|
|
expandedPath = homedir() + p.substring(1);
|
2025-08-06 02:01:01 +09:00
|
|
|
}
|
|
|
|
|
return path.normalize(expandedPath);
|
|
|
|
|
}
|