mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
release: Factor out JSON read/write for later reuse
This commit is contained in:
parent
8155d6154d
commit
ea4b2ef8fb
1 changed files with 7 additions and 5 deletions
|
@ -25,10 +25,12 @@ if (!release) {
|
||||||
throw new Error('No release type included');
|
throw new Error('No release type included');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const readJson = (filename) => JSON.parse(fs.readFileSync(filename, {encoding: 'utf8', flag: 'r'}));
|
||||||
|
const writeJson = (filename, obj) => fs.writeFileSync(filename, JSON.stringify(obj, null, 2));
|
||||||
|
|
||||||
const changelog = fs.readFileSync('CHANGELOG.md', {encoding: 'utf8', flag: 'r'});
|
const changelog = fs.readFileSync('CHANGELOG.md', {encoding: 'utf8', flag: 'r'});
|
||||||
let packageJson = fs.readFileSync('./src/package.json', {encoding: 'utf8', flag: 'r'});
|
const pkg = readJson('./src/package.json');
|
||||||
packageJson = JSON.parse(packageJson);
|
const currentVersion = pkg.version;
|
||||||
const currentVersion = packageJson.version;
|
|
||||||
|
|
||||||
const newVersion = semver.inc(currentVersion, release);
|
const newVersion = semver.inc(currentVersion, release);
|
||||||
if (!newVersion) {
|
if (!newVersion) {
|
||||||
|
@ -44,9 +46,9 @@ if (!changelogIncludesVersion) {
|
||||||
|
|
||||||
console.log('Okay looks good, lets create the package.json and package-lock.json');
|
console.log('Okay looks good, lets create the package.json and package-lock.json');
|
||||||
|
|
||||||
packageJson.version = newVersion;
|
pkg.version = newVersion;
|
||||||
|
|
||||||
fs.writeFileSync('src/package.json', JSON.stringify(packageJson, null, 2));
|
writeJson('./src/package.json', pkg);
|
||||||
|
|
||||||
// run npm version `release` where release is patch, minor or major
|
// run npm version `release` where release is patch, minor or major
|
||||||
childProcess.execSync('npm install --package-lock-only', {cwd: 'src/'});
|
childProcess.execSync('npm install --package-lock-only', {cwd: 'src/'});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue