|
1 | 1 | import {fileExistsSync} from './fs.js' |
2 | 2 | import {cwd, joinPath, sniffForPath} from './path.js' |
| 3 | +import {isDevelopment} from './context/local.js' |
3 | 4 | import {execaSync} from 'execa' |
4 | 5 | import {Command, Config} from '@oclif/core' |
5 | 6 | import {Options} from '@oclif/core/interfaces' |
6 | 7 |
|
7 | 8 | export class ShopifyConfig extends Config { |
8 | 9 | constructor(options: Options) { |
9 | | - const currentPath = cwd() |
| 10 | + if (isDevelopment()) { |
| 11 | + const currentPath = cwd() |
10 | 12 |
|
11 | | - let path = sniffForPath() ?? currentPath |
12 | | - // Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`. |
13 | | - const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\/hydrogen/i.test(currentPath) |
14 | | - const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO |
15 | | - if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) { |
16 | | - path = execaSync('npm', ['prefix']).stdout.trim() |
17 | | - } |
18 | | - if (fileExistsSync(joinPath(path, 'package.json'))) { |
19 | | - // Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons: |
20 | | - // 1. To allow users to use an older version of Hydrogen. (to not force upgrades) |
21 | | - // 2. To allow the Hydrogen team to load a local version for testing. |
22 | | - options.pluginAdditions = { |
23 | | - core: ['@shopify/cli-hydrogen'], |
24 | | - path, |
| 13 | + let path = sniffForPath() ?? currentPath |
| 14 | + // Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`. |
| 15 | + const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\/hydrogen/i.test(currentPath) |
| 16 | + const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO |
| 17 | + if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) { |
| 18 | + path = execaSync('npm', ['prefix']).stdout.trim() |
25 | 19 | } |
26 | | - } |
27 | | - super(options) |
| 20 | + if (fileExistsSync(joinPath(path, 'package.json'))) { |
| 21 | + // Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons: |
| 22 | + // 1. To allow users to use an older version of Hydrogen. (to not force upgrades) |
| 23 | + // 2. To allow the Hydrogen team to load a local version for testing. |
| 24 | + options.pluginAdditions = { |
| 25 | + core: ['@shopify/cli-hydrogen'], |
| 26 | + path, |
| 27 | + } |
| 28 | + } |
| 29 | + super(options) |
28 | 30 |
|
29 | | - // @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it. |
30 | | - // eslint-disable-next-line @typescript-eslint/unbound-method |
31 | | - this.determinePriority = this.customPriority |
| 31 | + // @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it. |
| 32 | + // eslint-disable-next-line @typescript-eslint/unbound-method |
| 33 | + this.determinePriority = this.customPriority |
| 34 | + } |
32 | 35 | } |
33 | 36 |
|
34 | 37 | customPriority(commands: Command.Loadable[]): Command.Loadable | undefined { |
|
0 commit comments