Skip to content

Commit

Permalink
npm-scripts: improve replaceVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jun 26, 2023
1 parent 369a015 commit 217ce02
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,24 @@ function replaceVersion()
{
logInfo('replaceVersion()');

const files =
[
'node/lib/index.js',
'node/lib/index.d.ts',
'node/lib/Worker.js'
];
const files = fs.readdirSync('node/lib',
{
withFileTypes : true,
recursive : true
});

for (const file of files)
{
const text = fs.readFileSync(file, { encoding: 'utf8' });
if (!file.isFile())
{
continue;
}

const filePath = path.join('node/lib', file.name);
const text = fs.readFileSync(filePath, { encoding: 'utf8' });
const result = text.replace(/__MEDIASOUP_VERSION__/g, PKG.version);

fs.writeFileSync(file, result, { encoding: 'utf8' });
fs.writeFileSync(filePath, result, { encoding: 'utf8' });
}
}

Expand Down

0 comments on commit 217ce02

Please sign in to comment.