Skip to content

Commit 3ca5a3d

Browse files
committed
TS: Document nodeModulesRex
1 parent 804aef5 commit 3ca5a3d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • javascript/extractor/lib/typescript/src

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ function parseSingleFile(filename: string): {ast: ts.SourceFile, code: string} {
245245
return {ast, code};
246246
}
247247

248+
/**
249+
* Matches a path segment referencing a package in a node_modules folder, and extracts
250+
* two capture groups: the package name, and the relative path in the package.
251+
*
252+
* For example `lib/node_modules/@foo/bar/src/index.js` extracts the capture groups [`@foo/bar`, `src/index.js`].
253+
*/
248254
const nodeModulesRex = /[/\\]node_modules[/\\]((?:@[\w.-]+[/\\])?\w[\w.-]*)[/\\](.*)/;
249255

250256
function handleOpenProjectCommand(command: OpenProjectCommand) {

0 commit comments

Comments
 (0)