MCPcopy Index your code
hub / github.com/nodejs/node / markCwd

Function markCwd

lib/internal/util/inspect.js:1897–1921  ·  view source on GitHub ↗
(ctx, line, workingDirectory)

Source from the content-addressed store, hash-verified

1895}
1896
1897function markCwd(ctx, line, workingDirectory) {
1898 let cwdStartPos = StringPrototypeIndexOf(line, workingDirectory);
1899 let tempLine = '';
1900 let cwdLength = workingDirectory.length;
1901 if (cwdStartPos !== -1) {
1902 if (StringPrototypeSlice(line, cwdStartPos - 7, cwdStartPos) === 'file://') {
1903 cwdLength += 7;
1904 cwdStartPos -= 7;
1905 }
1906 const start = line[cwdStartPos - 1] === '(' ? cwdStartPos - 1 : cwdStartPos;
1907 const end = start !== cwdStartPos && StringPrototypeEndsWith(line, ')') ? -1 : line.length;
1908 const workingDirectoryEndPos = cwdStartPos + cwdLength + 1;
1909 const cwdSlice = StringPrototypeSlice(line, start, workingDirectoryEndPos);
1910
1911 tempLine += StringPrototypeSlice(line, 0, start);
1912 tempLine += ctx.stylize(cwdSlice, 'undefined');
1913 tempLine += StringPrototypeSlice(line, workingDirectoryEndPos, end);
1914 if (end === -1) {
1915 tempLine += ctx.stylize(')', 'undefined');
1916 }
1917 } else {
1918 tempLine += line;
1919 }
1920 return tempLine;
1921}
1922
1923function safeGetCWD() {
1924 let workingDirectory;

Callers 1

formatErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…