From 76dd6dd02752cb1b09009c98c8993d2457ab280b Mon Sep 17 00:00:00 2001 From: Max Isom Date: Tue, 1 Feb 2022 19:54:30 -0600 Subject: [PATCH] Fix Prisma path on Windows? (#499) --- CHANGELOG.md | 2 ++ src/utils/create-database-url.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b85c785..50dd658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Prisma no longer causes a crash when running on Windows ## [0.5.3] - 2022-02-01 ### Changed diff --git a/src/utils/create-database-url.ts b/src/utils/create-database-url.ts index becc973..d17789b 100644 --- a/src/utils/create-database-url.ts +++ b/src/utils/create-database-url.ts @@ -2,6 +2,14 @@ import {join} from 'path'; export const createDatabasePath = (directory: string) => join(directory, 'db.sqlite'); -const createDatabaseUrl = (directory: string) => `file:${createDatabasePath(directory)}`; +const createDatabaseUrl = (directory: string) => { + const url = `file:${createDatabasePath(directory)}`; + + if (process.platform === 'win32') { + return url.replaceAll(/\\/g, '\\\\'); + } + + return url; +}; export default createDatabaseUrl;