forked from ghostery/adblocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix codebook generation (ghostery#4096)
- Loading branch information
Showing
5 changed files
with
52 additions
and
45 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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import { promises as fs } from 'fs'; | ||
import { resolve, join } from 'path'; | ||
import { readFileSync, writeFileSync } from 'node:fs'; | ||
import { resolve, join, dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
(async () => { | ||
const engineSourcePath = resolve(__dirname, join('..', 'src', 'engine', 'engine.ts')); | ||
const engineSource = await fs.readFile(engineSourcePath, 'utf-8'); | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
await fs.writeFile( | ||
engineSourcePath, | ||
engineSource.replace( | ||
/(^export const ENGINE_VERSION =\s+)(\d+)(;$)/m, | ||
(match, prefix, version, suffix, offset) => { | ||
console.log('Match:', { match, prefix, version, suffix, offset }); | ||
const engineSourcePath = resolve(__dirname, join('..', 'src', 'engine', 'engine.ts')); | ||
const engineSource = readFileSync(engineSourcePath, 'utf-8'); | ||
|
||
const currentVersion = Number(version); | ||
console.log('Current version:', currentVersion); | ||
writeFileSync( | ||
engineSourcePath, | ||
engineSource.replace( | ||
/(^export const ENGINE_VERSION =\s+)(\d+)(;$)/m, | ||
(match, prefix, version, suffix, offset) => { | ||
console.log('Match:', { match, prefix, version, suffix, offset }); | ||
|
||
const nextVersion = currentVersion + 1; | ||
console.log('Next version:', nextVersion); | ||
const currentVersion = Number(version); | ||
console.log('Current version:', currentVersion); | ||
|
||
return `${prefix}${nextVersion}${suffix}`; | ||
}, | ||
), | ||
'utf-8', | ||
); | ||
})(); | ||
const nextVersion = currentVersion + 1; | ||
console.log('Next version:', nextVersion); | ||
|
||
return `${prefix}${nextVersion}${suffix}`; | ||
}, | ||
), | ||
'utf-8', | ||
); |
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
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