-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProjectParser): add
typeDocJsonParserVersion
property
- Loading branch information
1 parent
99de280
commit 901d9ec
Showing
4 changed files
with
43 additions
and
3 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
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,26 @@ | ||
import { cyan, green } from 'colorette'; | ||
import { readdir, readFile, stat, writeFile } from 'node:fs/promises'; | ||
import { resolve, sep } from 'node:path'; | ||
|
||
const packageJson = JSON.parse(await readFile(resolve(process.cwd(), 'package.json'), 'utf8')); | ||
|
||
async function versionInjector(path) { | ||
const fileNames = await readdir(resolve(path)); | ||
|
||
for (const fileName of fileNames) { | ||
const file = await stat(resolve(path, fileName)); | ||
|
||
if (file.isDirectory()) await versionInjector(resolve(path, fileName)); | ||
else if (file.isFile() && fileName.endsWith('.js')) { | ||
const content = await readFile(resolve(path, fileName), 'utf8'); | ||
|
||
if (content.includes('[@versionInjector]')) { | ||
console.log(`${green('[@versionInjector]')} ${cyan(`${path}${sep}${fileName}`)}`); | ||
|
||
await writeFile(resolve(path, fileName), content.replace(/\[@versionInjector\]/g, packageJson.version)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
await versionInjector(resolve(process.cwd(), 'dist')); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"include": ["jest.config.mjs", "src", "tests"] | ||
"include": ["jest.config.mjs", "src", "tests", "scripts"] | ||
} |