chore: consistently import node modules with prefix (#3013)

Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
Pascal Birchler
2025-08-25 22:11:27 +02:00
committed by GitHub
parent 415d3413c4
commit ee4feea006
168 changed files with 420 additions and 405 deletions

View File

@@ -5,9 +5,9 @@
*/
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import { tmpdir } from 'os';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { tmpdir } from 'node:os';
import {
Config,
ConfigParameters,

View File

@@ -5,8 +5,8 @@
*/
import { describe, it, expect, vi, beforeEach, afterEach, Mock } from 'vitest';
import * as os from 'os';
import * as path from 'path';
import * as os from 'node:os';
import * as path from 'node:path';
import { ShellTool, EditTool, WriteFileTool } from '@google/gemini-cli-core';
import { loadCliConfig, parseArguments, CliArgs } from './config.js';
import { Settings } from './settings.js';
@@ -20,7 +20,7 @@ vi.mock('./trustedFolders.js', () => ({
vi.mock('fs', async (importOriginal) => {
const actualFs = await importOriginal<typeof import('fs')>();
const pathMod = await import('path');
const pathMod = await import('node:path');
const mockHome = '/mock/home/user';
const MOCK_CWD1 = process.cwd();
const MOCK_CWD2 = pathMod.resolve(pathMod.sep, 'home', 'user', 'project');

View File

@@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'fs';
import * as path from 'path';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { homedir } from 'node:os';
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';

View File

@@ -5,9 +5,9 @@
*/
import { vi } from 'vitest';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import {
EXTENSIONS_CONFIG_FILENAME,
INSTALL_METADATA_FILENAME,
@@ -17,7 +17,7 @@ import {
uninstallExtension,
updateExtension,
} from './extension.js';
import { execSync } from 'child_process';
import { execSync } from 'node:child_process';
import { SimpleGit, simpleGit } from 'simple-git';
vi.mock('simple-git', () => ({

View File

@@ -9,9 +9,9 @@ import {
GeminiCLIExtension,
Storage,
} from '@google/gemini-cli-core';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as os from 'node:os';
import { simpleGit } from 'simple-git';
export const EXTENSIONS_DIRECTORY_NAME = '.gemini/extensions';

View File

@@ -7,7 +7,7 @@
/// <reference types="vitest/globals" />
// Mock 'os' first.
import * as osActual from 'os'; // Import for type info for the mock factory
import * as osActual from 'node:os'; // Import for type info for the mock factory
vi.mock('os', async (importOriginal) => {
const actualOs = await importOriginal<typeof osActual>();
return {
@@ -33,7 +33,7 @@ vi.mock('./trustedFolders.js', () => ({
}));
// NOW import everything else, including the (now effectively re-exported) settings.js
import * as pathActual from 'path'; // Restored for MOCK_WORKSPACE_SETTINGS_PATH
import * as pathActual from 'node:path'; // Restored for MOCK_WORKSPACE_SETTINGS_PATH
import {
describe,
it,
@@ -44,7 +44,7 @@ import {
type Mocked,
type Mock,
} from 'vitest';
import * as fs from 'fs'; // fs will be mocked separately
import * as fs from 'node:fs'; // fs will be mocked separately
import stripJsonComments from 'strip-json-comments'; // Will be mocked separately
import { isWorkspaceTrusted } from './trustedFolders.js';

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'fs';
import * as path from 'path';
import { homedir, platform } from 'os';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { homedir, platform } from 'node:os';
import * as dotenv from 'dotenv';
import {
GEMINI_CONFIG_DIR as GEMINI_DIR,

View File

@@ -5,7 +5,7 @@
*/
// Mock 'os' first.
import * as osActual from 'os';
import * as osActual from 'node:os';
vi.mock('os', async (importOriginal) => {
const actualOs = await importOriginal<typeof osActual>();
return {
@@ -25,9 +25,9 @@ import {
type Mocked,
type Mock,
} from 'vitest';
import * as fs from 'fs';
import * as fs from 'node:fs';
import stripJsonComments from 'strip-json-comments';
import * as path from 'path';
import * as path from 'node:path';
import {
loadTrustedFolders,

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'fs';
import * as path from 'path';
import { homedir } from 'os';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { homedir } from 'node:os';
import { getErrorMessage, isWithinRoot } from '@google/gemini-cli-core';
import { Settings } from './settings.js';
import stripJsonComments from 'strip-json-comments';