Skip to content

Commit

Permalink
chore: rename extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
2wce committed Aug 13, 2024
1 parent c1d8c36 commit 2b8b7fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions patch-paths.cjs → patch-paths.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const fs = require('fs');
const glob = require('glob');
import { readFileSync, writeFileSync } from 'node:fs';
import { sync } from 'glob';

// Function to update require statements in a file
const updateRequireStatements = filePath => {
const content = fs.readFileSync(filePath, 'utf8');
const content = readFileSync(filePath, 'utf8');
const updatedContent = content.replace(
/require\((['"]\.\/[^'"]+)\.js(['"])\)/g,
'require($1.cjs$2)',
);
fs.writeFileSync(filePath, updatedContent, 'utf8');
writeFileSync(filePath, updatedContent, 'utf8');
console.log(`Updated require statements in ${filePath}`);
};

// Find all .cjs files in the dist directory
const cjsFiles = glob.sync('dist/**/*.cjs');
const cjsFiles = sync('dist/**/*.cjs');

// Update each .cjs file
cjsFiles.forEach(updateRequireStatements);
Expand Down
File renamed without changes.

0 comments on commit 2b8b7fd

Please sign in to comment.