---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [scaffold](../index.md) / detectSourceFromPath

# Function: detectSourceFromPath()

> **detectSourceFromPath**(`param`, `contextPath`, `projectRoot`): [`SourceDetectionResult`](../interfaces/SourceDetectionResult.md) \| `undefined`

Defined in: [packages/b2c-tooling-sdk/src/scaffold/sources.ts:245](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/scaffold/sources.ts#L245)

Detect a parameter's source value from a filesystem context path.

For `cartridges` source: walks up from `contextPath` looking for a `.project` file
(cartridge marker), stopping at projectRoot. On match returns the cartridge name and
companion path variable.

## Parameters

### param

[`ScaffoldParameter`](../interfaces/ScaffoldParameter.md)

The scaffold parameter with a `source` field

### contextPath

`string`

Filesystem path providing context (e.g., right-clicked folder)

### projectRoot

`string`

Project root directory

## Returns

[`SourceDetectionResult`](../interfaces/SourceDetectionResult.md) \| `undefined`

Detection result, or undefined if the source could not be detected
