Skip to content

Commit 3125161

Browse files
committed
chore: Remove replace-in-file
1 parent c548c3c commit 3125161

File tree

3 files changed

+31
-75
lines changed

3 files changed

+31
-75
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"nodemon": "^2.0.16",
121121
"npm-run-all": "^4.1.5",
122122
"prettier": "^3.1.1",
123-
"replace-in-file": "^4.0.0",
124123
"rimraf": "^3.0.2",
125124
"rollup": "^4.13.0",
126125
"rollup-plugin-cleanup": "^3.2.1",

scripts/versionbump.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
const replace = require('replace-in-file');
1+
const { readFile, writeFile } = require('node:fs').promises;
22
const pjson = require(`${process.cwd()}/package.json`);
33

4-
const files = process.argv.slice(2);
5-
if (files.length === 0) {
6-
console.error('Please provide files to bump');
7-
process.exit(1);
8-
}
4+
const REPLACE_REGEX = /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g;
5+
6+
async function run() {
7+
const files = process.argv.slice(2);
8+
if (files.length === 0) {
9+
// eslint-disable-next-line no-console
10+
console.error('[versionbump] Please provide files to bump');
11+
process.exit(1);
12+
}
913

10-
replace({
11-
files: files,
12-
from: /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g,
13-
to: pjson.version,
14-
})
15-
.then(changedFiles => {
16-
console.log('Modified files:', changedFiles.join(', '));
17-
})
18-
.catch(error => {
19-
console.error('Error occurred:', error);
14+
try {
15+
await Promise.all(
16+
files.map(async file => {
17+
const data = String(await readFile(file, 'utf8'));
18+
await writeFile(file, data.replace(REPLACE_REGEX, pjson.version));
19+
}),
20+
);
21+
22+
// eslint-disable-next-line no-console
23+
console.log(`[versionbump] Bumped version for ${files.join(', ')}`);
24+
} catch (error) {
25+
// eslint-disable-next-line no-console
26+
console.error('[versionbump] Error occurred:', error);
2027
process.exit(1);
21-
});
28+
}
29+
}
30+
31+
run();

yarn.lock

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13855,7 +13855,7 @@ [email protected]:
1385513855
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"
1385613856
integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==
1385713857

13858-
camelcase@^5.0.0, camelcase@^5.3.1:
13858+
camelcase@^5.3.1:
1385913859
version "5.3.1"
1386013860
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
1386113861
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
@@ -14278,15 +14278,6 @@ clipboardy@^4.0.0:
1427814278
is-wsl "^3.1.0"
1427914279
is64bit "^2.0.0"
1428014280

14281-
cliui@^6.0.0:
14282-
version "6.0.0"
14283-
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
14284-
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
14285-
dependencies:
14286-
string-width "^4.2.0"
14287-
strip-ansi "^6.0.0"
14288-
wrap-ansi "^6.2.0"
14289-
1429014281
cliui@^7.0.2:
1429114282
version "7.0.4"
1429214283
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
@@ -15434,7 +15425,7 @@ decamelize-keys@^1.1.0:
1543415425
decamelize "^1.1.0"
1543515426
map-obj "^1.0.0"
1543615427

15437-
decamelize@^1.1.0, decamelize@^1.2.0:
15428+
decamelize@^1.1.0:
1543815429
version "1.2.0"
1543915430
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
1544015431
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
@@ -19183,7 +19174,7 @@ get-amd-module-type@^5.0.1:
1918319174
ast-module-types "^5.0.0"
1918419175
node-source-walk "^6.0.1"
1918519176

19186-
get-caller-file@^2.0.1, get-caller-file@^2.0.5:
19177+
get-caller-file@^2.0.5:
1918719178
version "2.0.5"
1918819179
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
1918919180
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
@@ -29451,15 +29442,6 @@ repeat-string@^1.6.1:
2945129442
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
2945229443
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
2945329444

29454-
replace-in-file@^4.0.0:
29455-
version "4.3.1"
29456-
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-4.3.1.tgz#c67c92178b38052008e379197cc0d86ca927f7b0"
29457-
integrity sha512-FqVvfmpqGTD2JRGI1JjJ86b24P17x/WWwGdxExeyJxnh/2rVQz2+jXfD1507UnnhEQw092X0u0DPCBf1WC4ooQ==
29458-
dependencies:
29459-
chalk "^2.4.2"
29460-
glob "^7.1.6"
29461-
yargs "^15.0.2"
29462-
2946329445
require-at@^1.0.6:
2946429446
version "1.0.6"
2946529447
resolved "https://registry.yarnpkg.com/require-at/-/require-at-1.0.6.tgz#9eb7e3c5e00727f5a4744070a7f560d4de4f6e6a"
@@ -29484,11 +29466,6 @@ require-in-the-middle@^7.1.1:
2948429466
module-details-from-path "^1.0.3"
2948529467
resolve "^1.22.1"
2948629468

29487-
require-main-filename@^2.0.0:
29488-
version "2.0.0"
29489-
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
29490-
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
29491-
2949229469
requireindex@^1.2.0:
2949329470
version "1.2.0"
2949429471
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
@@ -34410,11 +34387,6 @@ which-collection@^1.0.1:
3441034387
is-weakmap "^2.0.2"
3441134388
is-weakset "^2.0.3"
3441234389

34413-
which-module@^2.0.0:
34414-
version "2.0.0"
34415-
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
34416-
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
34417-
3441834390
which-pm-runs@^1.1.0:
3441934391
version "1.1.0"
3442034392
resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.1.0.tgz#35ccf7b1a0fce87bd8b92a478c9d045785d3bf35"
@@ -34578,7 +34550,7 @@ workerpool@^6.4.0:
3457834550
string-width "^4.1.0"
3457934551
strip-ansi "^6.0.0"
3458034552

34581-
wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
34553+
wrap-ansi@^6.0.1:
3458234554
version "6.2.0"
3458334555
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
3458434556
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
@@ -34791,14 +34763,6 @@ [email protected], yargs-parser@^21.0.0, yargs-parser@^21.1.1:
3479134763
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
3479234764
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
3479334765

34794-
yargs-parser@^18.1.2:
34795-
version "18.1.3"
34796-
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
34797-
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
34798-
dependencies:
34799-
camelcase "^5.0.0"
34800-
decamelize "^1.2.0"
34801-
3480234766
[email protected], yargs@^16.1.1, yargs@^16.2.0:
3480334767
version "16.2.0"
3480434768
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
@@ -34825,23 +34789,6 @@ [email protected]:
3482534789
y18n "^5.0.5"
3482634790
yargs-parser "^21.0.0"
3482734791

34828-
yargs@^15.0.2:
34829-
version "15.4.1"
34830-
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
34831-
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
34832-
dependencies:
34833-
cliui "^6.0.0"
34834-
decamelize "^1.2.0"
34835-
find-up "^4.1.0"
34836-
get-caller-file "^2.0.1"
34837-
require-directory "^2.1.1"
34838-
require-main-filename "^2.0.0"
34839-
set-blocking "^2.0.0"
34840-
string-width "^4.2.0"
34841-
which-module "^2.0.0"
34842-
y18n "^4.0.0"
34843-
yargs-parser "^18.1.2"
34844-
3484534792
yargs@^17.2.1:
3484634793
version "17.7.2"
3484734794
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"

0 commit comments

Comments
 (0)