import { readFile, readdir, rename, writeFile } from 'node:fs/promises' import { join } from 'node:path' async function jstots() { const res = await readdir('src') for (let index = 0; index < res.length; index++) { const name = res[index] const targetname = join('target', `${name.slice(0, -3)}.ts`) await rename(join('src', name), targetname) console.log(targetname) } } async function removeImportJs() { const res = await readdir('src') for (let index = 0; index < res.length; index++) { const name = res[index] const targetname = join('target', `${name.slice(0, -3)}.ts`) const jsSourceStr = await readFile(join('src', name), { encoding: 'utf-8' }) const transSourceStr = jsSourceStr.replaceAll('.js', '') await writeFile(targetname, transSourceStr) console.log(targetname) } } removeImportJs()