Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/cli-kit/src/public/node/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import {sep, join} from 'pathe'
import {findUp as internalFindUp, findUpSync as internalFindUpSync} from 'find-up'
import {minimatch} from 'minimatch'
import fastGlobLib from 'fast-glob'
import {createRequire} from 'module'
import {
mkdirSync as fsMkdirSync,
readFileSync as fsReadFileSync,
Expand Down Expand Up @@ -58,6 +58,8 @@ import * as os from 'os'

import type {Pattern, Options as GlobOptions} from 'fast-glob'

const require = createRequire(import.meta.url)

/**
* Strip the first `strip` parts of the path.
*
Expand Down Expand Up @@ -598,7 +600,7 @@ export function globSync(pattern: Pattern | Pattern[], options?: GlobOptions): s
if (options?.dot == null) {
overridenOptions = {...options, dot: true}
}
return fastGlobLib.sync(pattern, overridenOptions)
return require('fast-glob').sync(pattern, overridenOptions)
}

/**
Expand Down
11 changes: 8 additions & 3 deletions packages/cli-kit/src/public/node/is-global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {cwd, dirname, joinPath, sniffForPath} from './path.js'
import {isUnitTest} from './context/local.js'
import {findPathUpSync, globSync} from './fs.js'
import {findPathUpSync, globSync, fileExistsSync} from './fs.js'
import {realpathSync} from 'fs'
import type {PackageManager} from './node-package-manager.js'

Expand Down Expand Up @@ -124,9 +124,14 @@ export function inferPackageManagerForGlobalCLI(argv = process.argv, env = proce
* @returns The project root directory, or undefined if not found.
*/
export function getProjectDir(directory: string): string | undefined {
const configFiles = ['shopify.app{,.*}.toml', 'hydrogen.config.js', 'hydrogen.config.ts']
const configFiles = ['shopify.app.toml', 'hydrogen.config.js', 'hydrogen.config.ts']
const existsConfigFile = (directory: string) => {
const configPaths = globSync(configFiles.map((file) => joinPath(directory, file)))
for (const file of configFiles) {
const configPath = joinPath(directory, file)
if (fileExistsSync(configPath)) return configPath
}

const configPaths = globSync(joinPath(directory, 'shopify.app.*.toml'))
return configPaths.length > 0 ? configPaths[0] : undefined
}
try {
Expand Down
Loading