Skip to content

Commit ab1c66a

Browse files
committed
wip
1 parent 1ce00c5 commit ab1c66a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/cli-kit/src/public/node/themes/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Theme} from './types.js'
22
import {renderTextPrompt} from '../ui.js'
33
import {getRandomName} from '../../common/string.js'
4+
import {platform} from 'os'
45

56
const GID_REGEXP = /gid:\/\/shopify\/\w*\/(\d+)/
67

@@ -33,3 +34,13 @@ export function parseGid(gid: string): number {
3334
}
3435
throw new Error(`Invalid GID: ${gid}`)
3536
}
37+
38+
export function filePathToFileUrl(filePath: string): string {
39+
let normalized = filePath.replace(/\\/g, '/')
40+
41+
if (platform() === 'win32') {
42+
normalized = `/${normalized}`
43+
}
44+
45+
return encodeURI(`file://${normalized}`)
46+
}

packages/theme/src/cli/services/profile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {joinPath} from '@shopify/cli-kit/node/path'
88
import {AdminSession} from '@shopify/cli-kit/node/session'
99
import {writeFile, tempDirectory} from '@shopify/cli-kit/node/fs'
1010
import {outputResult, outputDebug} from '@shopify/cli-kit/node/output'
11+
import {filePathToFileUrl} from '@shopify/cli-kit/node/themes/utils'
1112

1213
export async function profile(
1314
adminSession: AdminSession,
@@ -71,7 +72,7 @@ async function openProfile(profileJson: string) {
7172
await writeFile(htmlPath, `<script>window.location=${JSON.stringify(urlToOpen)}</script>`)
7273
outputDebug(`[Theme Profile] HTML file created successfully: ${htmlPath}`)
7374

74-
urlToOpen = `file://${htmlPath}`
75+
urlToOpen = filePathToFileUrl(htmlPath)
7576
outputDebug(`[Theme Profile] Opening URL: ${urlToOpen}`)
7677
const opened = await openURL(urlToOpen)
7778
outputDebug(`[Theme Profile] URL opened successfully: ${opened}`)

0 commit comments

Comments
 (0)