Skip to content

Commit ab1b9df

Browse files
committed
fix: replace require() with ES module imports
Removed all require() calls and replaced with proper ES module imports. The package uses type: module so require() is not available. Fixed in: - core/utils.ts: added appendFileSync import - core/audit-logger.ts: added mkdirSync import - extension/ext-publish-matrix.ts: added readFileSync import
1 parent 9d4a1de commit ab1b9df

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/vscode-extension-ci/src/core/audit-logger.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* repo root or https://opensource.org/licenses/BSD-3-Clause
77
*/
88

9-
import { appendFileSync, existsSync } from 'fs';
9+
import { appendFileSync, existsSync, mkdirSync } from 'fs';
1010
import { join } from 'path';
1111

1212
interface AuditLogEntry {
@@ -39,8 +39,7 @@ function getAuditLogPath(): string {
3939
// Ensure log directory exists
4040
if (!existsSync(logDir)) {
4141
// Create directory if it doesn't exist
42-
const fs = require('fs');
43-
fs.mkdirSync(logDir, { recursive: true });
42+
mkdirSync(logDir, { recursive: true });
4443
}
4544

4645
return logFile;

packages/vscode-extension-ci/src/core/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
* repo root or https://opensource.org/licenses/BSD-3-Clause
77
*/
88

9-
import { readFileSync, existsSync } from 'fs';
9+
import { readFileSync, existsSync, appendFileSync } from 'fs';
1010
import { join } from 'path';
1111
import { z } from 'zod';
1212
import chalk from 'chalk';
13+
import { execSync } from 'child_process';
1314
import type { SemanticVersion } from './types.js';
1415
import semver from 'semver';
1516

@@ -123,8 +124,7 @@ export function parseEnvironment(): {
123124
export function setOutput(name: string, value: string): void {
124125
const githubOutput = process.env['GITHUB_OUTPUT'];
125126
if (githubOutput) {
126-
const fs = require('fs');
127-
fs.appendFileSync(githubOutput, `${name}=${value}\n`);
127+
appendFileSync(githubOutput, `${name}=${value}\n`);
128128
} else {
129129
// Fallback for local development outside GitHub Actions
130130
console.log(`[output] ${name}=${value}`);

packages/vscode-extension-ci/src/extension/ext-publish-matrix.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { log } from '../core/utils.js';
11-
import { readdirSync, existsSync } from 'fs';
11+
import { readdirSync, existsSync, readFileSync } from 'fs';
1212
import { join } from 'path';
1313

1414
interface PublishMatrixEntry {
@@ -45,7 +45,7 @@ function getAvailableExtensions(): string[] {
4545
if (existsSync(packageJsonPath)) {
4646
try {
4747
const packageJson = JSON.parse(
48-
require('fs').readFileSync(packageJsonPath, 'utf-8'),
48+
readFileSync(packageJsonPath, 'utf-8'),
4949
);
5050

5151
// Only include packages that have a publisher (VS Code extensions)

0 commit comments

Comments
 (0)