Skip to content

Commit

Permalink
Package: fix import transform regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 19, 2024
1 parent 4224ca8 commit 2501614
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions node-import-transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Assumtions:
* Assumptions:
* 1. no imports from 'foo/foo' where foo/foo/index.js exists
*/
import { spawnSync } from 'child_process'
Expand Down Expand Up @@ -27,7 +27,7 @@ const dirImports = exec([`find`, `dist`, `-name`, `index.js`])
.filter(p => p.length > 2)
.map(p => p.at(-2)!)
dirImports.forEach(d => {
exec([...findCmd, `sed`, `-i`, `-E`, `s|(from '\\..+${d})(')|\\1/index\\2|g`, `{}`, `+`])
exec([...findCmd, `sed`, `-i`, `-E`, `s|(from '.*\./${d})(')|\\1/index\\2|g`, `{}`, `+`])
})

// fix from '.' -> from './index'
Expand Down

0 comments on commit 2501614

Please sign in to comment.