Skip to content

Commit

Permalink
Merge pull request #5252 from Shopify/fd-fix-nx-dep
Browse files Browse the repository at this point in the history
[Theme] Change how assets are resolved
  • Loading branch information
frandiox authored Jan 22, 2025
2 parents da30052 + 6121c3d commit 7b3ba77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
"ignoreDependencies": [
"eslint-plugin-react",
"eslint-plugin-react-hooks",
"@shopify/cli",
"@shopify/cli-hydrogen",
"@shopify/theme-check-node",
"@shopify/theme-check-docs-updater"
Expand Down
21 changes: 13 additions & 8 deletions packages/theme/src/cli/utilities/asset-path.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import {dirname, joinPath} from '@shopify/cli-kit/node/path'
import {createRequire} from 'node:module'

const require = createRequire(import.meta.url)
import {findPathUp} from '@shopify/cli-kit/node/fs'
import {joinPath, dirname} from '@shopify/cli-kit/node/path'
import {fileURLToPath} from 'node:url'

export async function resolveAssetPath(...subpaths: string[]) {
if (process.env.SHOPIFY_UNIT_TEST) {
return joinPath(__dirname, '..', '..', '..', ...subpaths)
const rootPkgJon = await findPathUp('package.json', {
cwd: fileURLToPath(import.meta.url),
type: 'file',
})

if (!rootPkgJon) {
throw new Error('Failed to find CLI root path')
}

const cliRootPath = dirname(require.resolve('@shopify/cli/package.json'))
return joinPath(cliRootPath, 'dist', 'assets', ...subpaths)
return rootPkgJon.endsWith('/packages/theme/package.json')
? joinPath(dirname(rootPkgJon), 'assets', ...subpaths)
: joinPath(dirname(rootPkgJon), 'dist', 'assets', ...subpaths)
}

0 comments on commit 7b3ba77

Please sign in to comment.