Skip to content

Commit b5f206b

Browse files
committed
Fix file paths not resolving on windows
1 parent 68eacb8 commit b5f206b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/create-next-stack/src/scripts/file-list-to-array.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
// This script reads each line of stdin and outputs a JSON array of the lines.
2-
// This is useful for passing a list of files to a command.
3-
// Example usage: `ls | node file-list-to-array.ts`
1+
import { resolve } from "path"
2+
3+
/*
4+
This script reads each line of stdin and outputs a JSON array of the lines.
5+
This is useful for passing a list of files to a command.
6+
Example usage: `ls | node file-list-to-array.ts`
7+
*/
8+
49
let input = ""
510
process.stdin.on("data", (data) => {
611
input += data.toString()
712
})
813
process.stdin.on("end", () => {
914
const filePaths = input.split("\n").filter(Boolean)
1015
const files = filePaths.map((filePath) => ({
11-
filePath: filePath,
16+
filePath: filePath.replace(resolve(process.cwd()) + "/", ""),
1217
fileName: filePath.split("/").pop()?.split(".")[0] || filePath,
1318
}))
1419
console.log(JSON.stringify(files))

0 commit comments

Comments
 (0)