MCPcopy
hub / github.com/commitizen/cz-cli / resolveAdapterPath

Function resolveAdapterPath

src/commitizen/adapter.js:158–175  ·  view source on GitHub ↗

* Given a resolvable module name or path, which can be a directory or file, will * return a located adapter path or will throw.

(inboundAdapterPath)

Source from the content-addressed store, hash-verified

156 * return a located adapter path or will throw.
157 */
158function resolveAdapterPath (inboundAdapterPath) {
159 // Check if inboundAdapterPath is a path or node module name
160 let parsed = path.parse(inboundAdapterPath);
161 let isPath = parsed.dir.length > 0 && parsed.dir.charAt(0) !== "@";
162
163 // Resolve from the root of the git repo if inboundAdapterPath is a path
164 let absoluteAdapterPath = isPath ?
165 path.resolve(getGitRootPath(), inboundAdapterPath) :
166 inboundAdapterPath;
167
168 try {
169 // try to resolve the given path
170 return require.resolve(absoluteAdapterPath);
171 } catch (error) {
172 error.message = "Could not resolve " + absoluteAdapterPath + ". " + error.message;
173 throw error;
174 }
175}
176
177function getGitRootPath () {
178 return childProcess.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout.trim();

Callers 2

gitCzFunction · 0.85
getPrompterFunction · 0.85

Calls 1

getGitRootPathFunction · 0.85

Tested by

no test coverage detected