Skip to content

Commit fb55aca

Browse files
Updated script to use import.
1 parent ad98505 commit fb55aca

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/version-update.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
const fs = require("fs");
2-
const path = require("path");
1+
import fs from "fs";
2+
import path from "path";
3+
import { fileURLToPath } from "url";
4+
5+
// Resolve __dirname in ES module
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
38

49
const appConfigPath = path.join(__dirname, "../app.config.js");
5-
const appConfig = require(appConfigPath);
10+
11+
// Import `app.config.js` dynamically
12+
const { default: appConfig } = await import(appConfigPath);
613

714
// Split version into major.minor.patch
815
const [major, minor, patch] = appConfig.expo.version.split(".").map(Number);
@@ -11,6 +18,7 @@ const newVersion = `${major}.${minor}.${patch + 1}`;
1118
// Update build number (Android versionCode)
1219
const newBuildNumber = (appConfig.expo.android.versionCode || 1) + 1;
1320

21+
// Generate updated configuration
1422
const updatedConfig = `export default ${JSON.stringify(
1523
{
1624
...appConfig,
@@ -31,5 +39,6 @@ const updatedConfig = `export default ${JSON.stringify(
3139
2
3240
).replace(/"([^"]+)":/g, "$1:")};`;
3341

42+
// Write updated configuration back to file
3443
fs.writeFileSync(appConfigPath, updatedConfig);
3544
console.log(`Updated to v${newVersion} (build ${newBuildNumber})`);

0 commit comments

Comments
 (0)