mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-21 15:06:45 +02:00
826384b9d5
* Resolve bug with setChoiceByValue not removing choice from dropdown * 4.1.3 * Version 4.1.3
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const config = {
|
|
files: ['public/index.html'],
|
|
};
|
|
|
|
/**
|
|
* Convert node arguments into an object
|
|
* @return {Object} Arguments
|
|
*/
|
|
const argvToObject = () => {
|
|
const args = {};
|
|
let arg = null;
|
|
process.argv.forEach((val, index) => {
|
|
if (/^--/.test(val)) {
|
|
arg = {
|
|
index,
|
|
name: val.replace(/^--/, ''),
|
|
};
|
|
return;
|
|
}
|
|
|
|
if (arg && arg.index + 1 === index) {
|
|
args[arg.name] = val;
|
|
}
|
|
});
|
|
|
|
return args;
|
|
};
|
|
|
|
/**
|
|
* Loop through files updating the current version
|
|
* @param {Object} config
|
|
*/
|
|
const updateVersion = ({ files }) => {
|
|
const args = argvToObject();
|
|
const version = args.current;
|
|
|
|
console.log(`Updating version to ${version}`);
|
|
|
|
files.forEach(file => {
|
|
const filePath = path.join(__dirname, file);
|
|
const regex = new RegExp(/\?version=(.*?)\"/, 'g');
|
|
|
|
let contents = fs.readFileSync(filePath, 'utf-8');
|
|
contents = contents.replace(regex, `?version=${version}"`);
|
|
fs.writeFileSync(filePath, contents);
|
|
});
|
|
|
|
console.log(`Updated version to ${version}`);
|
|
};
|
|
|
|
updateVersion(config);
|