-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d97c294
commit 53a4c31
Showing
3 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const { promises: fs } = require('fs'); | ||
const path = require('path'); | ||
const replace = require('replace-in-file'); | ||
|
||
const newDeprecationPattern = | ||
/<\s*a id="DEP0([X]+[0-9]*)+"[^>]*><\s*\/\s*a>/g; | ||
|
||
async function getUnmarkedDeprecations() { | ||
const deprecationFilePath = path.resolve('doc', 'api', 'deprecations.md'); | ||
const deprecationFile = await fs.readFile(deprecationFilePath, 'utf8'); | ||
|
||
const unmarkedDeprecations = [ | ||
...deprecationFile.matchAll(newDeprecationPattern) | ||
].map(m => m[1]); | ||
|
||
return unmarkedDeprecations; | ||
} | ||
|
||
async function updateDeprecations() { | ||
const deprecationPattern = | ||
/<\s*a id="DEP0([0-9]{3})+"[^>]*><\s*\/\s*a>/g; | ||
|
||
const deprecationFilePath = path.resolve('doc', 'api', 'deprecations.md'); | ||
const deprecationFile = await fs.readFile(deprecationFilePath, 'utf8'); | ||
|
||
const unmarkedDeprecations = await getUnmarkedDeprecations(); | ||
const deprecationNumbers = [ | ||
...deprecationFile.matchAll(deprecationPattern) | ||
].map(m => m[1]).reverse(); | ||
|
||
// Pull highest deprecation number off the list and increment from there. | ||
let depNumber = parseInt(deprecationNumbers[0]) + 1; | ||
|
||
// Loop through each new unmarked deprecation number and replace instances. | ||
for (const unmarked of unmarkedDeprecations) { | ||
await replace({ | ||
files: [ | ||
'doc/api/*.md', | ||
'lib/**/*.js', | ||
'src/**/*.{h,cc}', | ||
'test/**/*.js' | ||
], | ||
ignore: 'test/common/README.md', | ||
from: new RegExp(`DEP0${unmarked}`, 'g'), | ||
to: `DEP0${depNumber}` | ||
}); | ||
|
||
depNumber++; | ||
} | ||
} | ||
|
||
module.exports = { | ||
updateDeprecations, | ||
getUnmarkedDeprecations | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters