diff --git a/packages/dev/scripts/polkadot-dev-build-ts.mjs b/packages/dev/scripts/polkadot-dev-build-ts.mjs index e1c8dd205..5135a5b1a 100755 --- a/packages/dev/scripts/polkadot-dev-build-ts.mjs +++ b/packages/dev/scripts/polkadot-dev-build-ts.mjs @@ -293,10 +293,10 @@ function findFiles (buildDir, extra = '', exclude = []) { .readdirSync(currDir) .reduce((all, jsName) => { const jsPath = `${extra}/${jsName}`; - const thisPath = path.join(buildDir, jsPath); + const fullPathEsm = path.join(buildDir, jsPath); const toDelete = ( // no test paths - thisPath.includes('/test/') || + jsPath.includes('/test/') || // // no tests ['.manual.', '.spec.', '.test.'].some((t) => jsName.includes(t)) || // no .d.ts compiled outputs @@ -310,13 +310,13 @@ function findFiles (buildDir, extra = '', exclude = []) { ) ); - if (fs.statSync(thisPath).isDirectory()) { + if (fs.statSync(fullPathEsm).isDirectory()) { findFiles(buildDir, jsPath).forEach((entry) => all.push(entry)); } else if (toDelete) { - const cjsPath = path.join(`${buildDir}-cjs`, jsPath); + const fullPathCjs = path.join(`${buildDir}-cjs`, jsPath); - fs.unlinkSync(thisPath); - fs.existsSync(cjsPath) && fs.unlinkSync(cjsPath); + fs.unlinkSync(fullPathEsm); + fs.existsSync(fullPathCjs) && fs.unlinkSync(fullPathCjs); } else { if (!exclude.some((e) => jsName === e)) { // this is not mapped to a compiled .js file (where we have dual esm/cjs mappings)