File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
cli-kit/src/public/node/themes Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import { Theme } from './types.js'
22import { renderTextPrompt } from '../ui.js'
33import { getRandomName } from '../../common/string.js'
4+ import { platform } from 'os'
45
56const GID_REGEXP = / g i d : \/ \/ s h o p i f y \/ \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+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import {joinPath} from '@shopify/cli-kit/node/path'
88import { AdminSession } from '@shopify/cli-kit/node/session'
99import { writeFile , tempDirectory } from '@shopify/cli-kit/node/fs'
1010import { outputResult , outputDebug } from '@shopify/cli-kit/node/output'
11+ import { filePathToFileUrl } from '@shopify/cli-kit/node/themes/utils'
1112
1213export 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 } ` )
You can’t perform that action at this time.
0 commit comments