mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
21 lines
663 B
JavaScript
21 lines
663 B
JavaScript
|
const fs = require('fs-extra');
|
||
|
|
||
|
function replaceVersionPlaceholder(version) {
|
||
|
const staticJsFilesPath = './build/static/js';
|
||
|
const versionPlaceholder = '%_VERSION_%';
|
||
|
|
||
|
const isMainFile = (file) => file.startsWith('main.') && file.endsWith('.js');
|
||
|
const [ mainJsFile ] = fs.readdirSync(staticJsFilesPath).filter(isMainFile);
|
||
|
const filePath = `${staticJsFilesPath}/${mainJsFile}`;
|
||
|
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||
|
const replaced = fileContent.replace(versionPlaceholder, version);
|
||
|
|
||
|
fs.writeFileSync(filePath, replaced, 'utf-8');
|
||
|
}
|
||
|
|
||
|
const version = process.env.VERSION;
|
||
|
|
||
|
if (version) {
|
||
|
replaceVersionPlaceholder(version);
|
||
|
}
|