File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 22 "dependencies" : {
33 "markdown-magic" : " ^1.0.0" ,
44 "typescript" : " latest" ,
5- "glob" : " ^7.1.6"
5+ "glob" : " ^7.1.6" ,
6+ "escape-regex-string" : " ^1.0.6"
67 },
78 "scripts" : {
89 "build" : " md-magic --path '**/*.md'" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const glob = require("glob")
1616const { readFileSync, writeFileSync, existsSync} = require ( "fs" )
1717const { join} = require ( "path" )
1818const { execSync } = require ( "child_process" ) ;
19+ const escapeRegex = require ( "escape-regex-string" ) ;
1920
2021if ( ! process . argv [ 2 ] ) throw new Error ( "Did not include a glob for markdown files to change" )
2122
@@ -45,7 +46,7 @@ files.forEach(file => {
4546 const originalFile = readFileSync ( join ( repoPath , file ) , "utf8" )
4647 if ( ! originalFile ) throw new Error ( `Could not find a file at '${ join ( repoPath , file ) } '` )
4748
48- const line = getLineNo ( originalFile , new RegExp ( searchTerm ) )
49+ const line = getLineNo ( originalFile , new RegExp ( escapeRegex ( searchTerm ) ) )
4950 const lineRef = line && line [ 0 ] && line [ 0 ] . number ? `#L${ line [ 0 ] . number } ` : ""
5051 const replacement = `: https://github.com/microsoft/TypeScript/blob/${ repoHead . trim ( ) } /${ file } ${ lineRef } `
5152 content = content . replace ( original , replacement )
You can’t perform that action at this time.
0 commit comments