Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bflynn-cms authored Dec 10, 2024
2 parents 7f76267 + 83e17ae commit a0e7ccd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/ui-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "react-scripts build && node remove-versions.js",
"test": "react-scripts test --unhandled-rejections=strict",
"eject": "react-scripts eject"
},
Expand Down
53 changes: 53 additions & 0 deletions services/ui-src/remove-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const fs = require('fs');
const path = require('path');

// Define the directory of the build output
const buildDir = path.join(__dirname, 'build', 'static', 'js');

// Function to remove the version from files
const removeVersionFromFiles = (dir) => {
fs.readdir(dir, (err, files) => {
if (err) {
console.error("Error reading directory:", err);
return;
}

files.forEach(file => {
const filePath = path.join(dir, file);

// Check if the file is a JavaScript file
if (file.endsWith('.js')) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error("Error reading file:", err);
return;
}

// Replace the version pattern only if it matches the Bn.VERSION line
const regex = /(Bn\.VERSION=")([4-9]\.\d{2}\.\d{2})(")/;
const result = data.replace(regex, 'Bn.VERSION=""');

if (data !== result) {
console.log(`Updated content of ${file}:`);
} else {
console.log(`No version found in ${file}`);
}

// Write the modified content back to the file
fs.writeFile(filePath, result, 'utf8', (err) => {
if (err) {
console.error("Error writing file:", err);
} else {
console.log(`Version removed from ${file}`);
}
});
});
}
});
});
};

removeVersionFromFiles(buildDir);



0 comments on commit a0e7ccd

Please sign in to comment.