| 256 | // ─── cordova helpers ───────────────────────────────────────────────────────── |
| 257 | |
| 258 | function ensureCordovaFiles() { |
| 259 | // Copy cordova.js and any other platform_www files into www/ |
| 260 | // so the dev server can serve them when the app redirects to it. |
| 261 | if (!fs.existsSync(PLATFORM_WWW)) { |
| 262 | log("warn", "platform_www not found — skipping cordova file copy"); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | const files = fs.readdirSync(PLATFORM_WWW); |
| 267 | for (const file of files) { |
| 268 | const src = path.join(PLATFORM_WWW, file); |
| 269 | const dest = path.join(WWW, file); |
| 270 | if (fs.statSync(src).isFile()) { |
| 271 | // Don't overwrite index.html |
| 272 | if (file === "index.html") continue; |
| 273 | fs.copyFileSync(src, dest); |
| 274 | } |
| 275 | } |
| 276 | log("ok", "Copied cordova platform files to www/"); |
| 277 | } |
| 278 | |
| 279 | async function launchApp(target, platform, emulator) { |
| 280 | if (target) { |