Skip to content

Commit d1a66f6

Browse files
feat. show warning before syncing
1 parent 0d3e009 commit d1a66f6

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clean": "sh scripts/gradlew-link clean",
1010
"plugin": "sh utils/scripts/plugin.sh",
1111
"setup": "npx cap sync",
12-
"sync": "npx cap sync && node scripts/postSync.js",
12+
"sync": "node scripts/preSync.js",
1313
"lint": "biome lint --write",
1414
"format": "biome format --write",
1515
"check": "biome check --write",

scripts/preSync.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const readline = require('readline');
2+
const path = require('path');
3+
const { execSync } = require("child_process");
4+
5+
const rl = readline.createInterface({
6+
input: process.stdin,
7+
output: process.stdout
8+
});
9+
10+
11+
12+
console.log('\x1b[33m⚠️ WARNING:\x1b[0m The Android directory will be rebuilt.');
13+
console.log('\x1b[33mSome configuration files or other changes may be lost.\x1b[0m');
14+
console.log('\x1b[33mThis is usually not necessary and may break the build or cause build issues.\x1b[0m');
15+
16+
rl.question('Do you want to continue? (y/n): ', (answer) => {
17+
const normalized = answer.trim().toLowerCase();
18+
if (normalized === 'y') {
19+
console.log('\n🔁 Syncing with Capacitor...');
20+
rl.close();
21+
execSync("npx cap sync && node \"$(npm prefix)/scripts/postSync.js\"", { stdio: "inherit" });
22+
} else {
23+
console.log('\n🚫 Operation cancelled.');
24+
rl.close();
25+
}
26+
});

0 commit comments

Comments
 (0)