|
1 | | -const path = require('path'); |
2 | | -const fs = require('fs'); |
3 | 1 | const { execSync } = require('child_process'); |
| 2 | +const fs = require('fs'); |
| 3 | +const path = require('path'); |
4 | 4 |
|
5 | 5 | const PKG_JSON_PATH = path.join(__dirname, '..', '..', 'package.json'); |
6 | 6 |
|
7 | | -const pkgJson = require(PKG_JSON_PATH); |
| 7 | +const pkgJson = require(PKG_JSON_PATH); // eslint-disable-line import/no-dynamic-require |
8 | 8 |
|
9 | 9 | const PACKAGE_NAME = pkgJson.name; |
10 | 10 | const VERSION = pkgJson.version; |
11 | 11 |
|
12 | 12 | const nextVersion = getNextVersion(VERSION); |
13 | | -console.log(`before-deploy: Setting version to ${nextVersion}`); |
| 13 | +console.log(`before-deploy: Setting version to ${nextVersion}`); // eslint-disable-line no-console |
14 | 14 | pkgJson.version = nextVersion; |
15 | 15 |
|
16 | | -fs.writeFileSync(PKG_JSON_PATH, JSON.stringify(pkgJson, null, 2) + '\n'); |
| 16 | +fs.writeFileSync(PKG_JSON_PATH, `${JSON.stringify(pkgJson, null, 2)}\n`); |
17 | 17 |
|
18 | 18 | function getNextVersion(version) { |
19 | | - const versionString = execSync(`npm show ${PACKAGE_NAME} versions --json`, { encoding: 'utf8'}); |
| 19 | + const versionString = execSync(`npm show ${PACKAGE_NAME} versions --json`, { encoding: 'utf8' }); |
20 | 20 | const versions = JSON.parse(versionString); |
21 | 21 |
|
22 | | - if (versions.some(v => v === VERSION)) { |
23 | | - console.error(`before-deploy: A release with version ${VERSION} already exists. Please increment version accordingly.`); |
| 22 | + if (versions.some((v) => v === VERSION)) { |
| 23 | + console.error(`before-deploy: A release with version ${VERSION} already exists. Please increment version accordingly.`); // eslint-disable-line no-console |
24 | 24 | process.exit(1); |
25 | 25 | } |
26 | 26 |
|
27 | 27 | const prereleaseNumbers = versions |
28 | | - .filter(v => (v.startsWith(VERSION) && v.includes('-'))) |
29 | | - .map(v => Number(v.match(/\.(\d+)$/)[1])); |
| 28 | + .filter((v) => (v.startsWith(VERSION) && v.includes('-'))) |
| 29 | + .map((v) => Number(v.match(/\.(\d+)$/)[1])); |
30 | 30 | const lastPrereleaseNumber = Math.max(-1, ...prereleaseNumbers); |
31 | | - return `${version}-beta.${lastPrereleaseNumber + 1}` |
| 31 | + return `${version}-beta.${lastPrereleaseNumber + 1}`; |
32 | 32 | } |
0 commit comments