mirror of
https://github.com/Choices-js/Choices.git
synced 2024-04-26 03:10:33 +02:00
Tweak version script to update to current npm version
This commit is contained in:
parent
e060ceaad4
commit
9a14daedc3
|
@ -1,10 +1,8 @@
|
|||
// Example usage: npm --newVersion=3.0.2 run version
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const config = {
|
||||
files: ['package.json', 'public/index.html', 'version.js'],
|
||||
files: ['public/index.html'],
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -37,21 +35,20 @@ const argvToObject = () => {
|
|||
*/
|
||||
const updateVersion = ({ files }) => {
|
||||
const args = argvToObject();
|
||||
const currentVersion = args.current;
|
||||
const newVersion = args.new || currentVersion;
|
||||
const version = args.current;
|
||||
|
||||
console.log(`Updating version from ${currentVersion} to ${newVersion}`);
|
||||
console.log(`Updating version to ${version}`);
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = path.join(__dirname, file);
|
||||
const regex = new RegExp(currentVersion, 'g');
|
||||
const regex = new RegExp(/\?version=(.*?)\"/, 'g');
|
||||
|
||||
let contents = fs.readFileSync(filePath, 'utf-8');
|
||||
contents = contents.replace(regex, newVersion);
|
||||
contents = contents.replace(regex, `?version=${version}"`);
|
||||
fs.writeFileSync(filePath, contents);
|
||||
});
|
||||
|
||||
console.log(`Updated version to ${newVersion}`);
|
||||
console.log(`Updated version to ${version}`);
|
||||
};
|
||||
|
||||
updateVersion(config);
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"baseUrl": "http://localhost:3001/test"
|
||||
"baseUrl": "http://localhost:3001/test",
|
||||
"video": false
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
"coverage": "nyc npm run test:unit",
|
||||
"cypress:run": "$(npm bin)/cypress run",
|
||||
"cypress:open": "$(npm bin)/cypress open",
|
||||
"test:unit": "mocha --require ./config/test.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\" --exit",
|
||||
"test:unit": "mocha --require ./config/jsdom.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\" --exit",
|
||||
"test:unit:watch": "npm run test:unit -- --watch --inspect=5556",
|
||||
"test:e2e": "run-p --race start cypress:run",
|
||||
"test": "run-p test:unit test:e2e",
|
||||
|
@ -24,7 +24,7 @@
|
|||
"css:sass": "node-sass --output-style expanded --include-path scss src/styles/base.scss public/assets/styles/base.css && node-sass --output-style expanded --include-path scss src/styles/choices.scss public/assets/styles/choices.css",
|
||||
"css:prefix": "postcss --use autoprefixer -b 'last 2 versions' public/assets/styles/*.css -d public/assets/styles",
|
||||
"css:min": "csso public/assets/styles/base.css public/assets/styles/base.min.css && csso public/assets/styles/choices.css public/assets/styles/choices.min.css",
|
||||
"version": "node version.js --current $npm_package_version",
|
||||
"bump-version": "node bump-version.js --current $npm_package_version",
|
||||
"gh-pages": "git subtree push --prefix public origin gh-pages",
|
||||
"postversion": "npm run js:build",
|
||||
"prepush": "run-p lint test:unit"
|
||||
|
|
Loading…
Reference in a new issue