cli: fix diff command filepath handling on windows

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-08-17 14:31:35 +02:00
parent 6f98aec868
commit 8ea1e96b32
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Fix file path handling in diff commands on Windows.
+2 -1
View File
@@ -16,6 +16,7 @@
import chalk from 'chalk';
import { diffLines } from 'diff';
import { sep, posix } from 'path';
import { FileDiff, PromptFunc, FileHandler, WriteFileFunc } from './types';
function sortObjectKeys(obj: Record<string, unknown>) {
@@ -281,7 +282,7 @@ export async function handleAllFiles(
promptFunc: PromptFunc,
) {
for (const file of files) {
const { path } = file;
const path = file.path.split(sep).join(posix.sep);
const fileHandler = fileHandlers.find(handler =>
handler.patterns.some(pattern =>
typeof pattern === 'string' ? pattern === path : pattern.test(path),