-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: correctly detect if file is outside base path on Windows (#59)
Co-authored-by: Milos Djermanovic <[email protected]>
- Loading branch information
1 parent
80eb545
commit f93aa4c
Showing
8 changed files
with
540 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
package-lock = false | ||
@jsr:registry=https://npm.jsr.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Replace import specifiers in "dist" modules to use the bundled versions of "@jsr/std__path". | ||
* | ||
* In "dist/cjs/index.cjs": | ||
* - '@jsr/std__path/posix' → './std__path/posix.cjs' | ||
* - '@jsr/std__path/windows' → './std__path/windows.cjs' | ||
* | ||
* In "dist/esm/index.js": | ||
* - '@jsr/std__path/posix' → './std__path/posix.js' | ||
* - '@jsr/std__path/windows' → './std__path/windows.js' | ||
*/ | ||
|
||
import { readFile, writeFile } from "node:fs/promises"; | ||
|
||
async function replaceInFile(file, search, replacement) { | ||
let text = await readFile(file, "utf-8"); | ||
text = text.replace(search, replacement); | ||
await writeFile(file, text); | ||
} | ||
|
||
const SEARCH_REGEXP = /'@jsr\/std__path\/(.+?)'/gu; | ||
|
||
await Promise.all([ | ||
replaceInFile("dist/cjs/index.cjs", SEARCH_REGEXP, "'./std__path/$1.cjs'"), | ||
replaceInFile("dist/esm/index.js", SEARCH_REGEXP, "'./std__path/$1.js'"), | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createRequire } from "node:module"; | ||
|
||
const { resolve } = createRequire(import.meta.url); | ||
|
||
export default [ | ||
{ | ||
input: resolve("@jsr/std__path/posix"), | ||
output: [ | ||
{ | ||
file: "./dist/cjs/std__path/posix.cjs", | ||
format: "cjs", | ||
}, | ||
{ | ||
file: "./dist/esm/std__path/posix.js", | ||
format: "esm", | ||
}, | ||
], | ||
}, | ||
{ | ||
input: resolve("@jsr/std__path/windows"), | ||
output: [ | ||
{ | ||
file: "./dist/cjs/std__path/windows.cjs", | ||
format: "cjs", | ||
}, | ||
{ | ||
file: "./dist/esm/std__path/windows.js", | ||
format: "esm", | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.