Skip to content

Commit

Permalink
feat: check for platform specific index
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Mar 5, 2023
1 parent 18fc9ab commit 65765a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions src/application/androidUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { getRootDestinationFolder } from './utils';
import { getProjectRootDir, getRootDestinationFolder } from "./utils";
import path from "path";
import fs from "fs";

export function getAppBuildFolder(flavorName?: string, release?: boolean) {
const buildType = release ? 'release' : 'debug';
const buildType = release ? "release" : "debug";

const appPath = `${getRootDestinationFolder()}/android/${flavorName ? `${flavorName}/` : ''}${buildType}`;
const appPath = `${getRootDestinationFolder()}/android/${flavorName ? `${flavorName}/` : ""}${buildType}`;
return appPath;
}

export function getAndroidIndexJsPath() {
const androidSpecific = path.join(getProjectRootDir(), "src", "application", "index.android.js");
if (fs.existsSync(androidSpecific)) {
return androidSpecific;
} else {
return path.join(getProjectRootDir(), "src", "application", "index.js");
}
}
6 changes: 3 additions & 3 deletions src/application/buildAndroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
getUberSignJava,
} from './utils';
import { getAndroidFlavors } from './config';
import { getAppBuildFolder } from './androidUtils';
import { getAndroidIndexJsPath, getAppBuildFolder } from "./androidUtils";
import fs from 'fs';

function capitalize(str: string) {
return str;
return str.charAt(0).toUpperCase() + str.slice(1);
}

async function rebuildIncrementallyTheApk(
Expand Down Expand Up @@ -78,7 +78,7 @@ async function rebuildIncrementally(buildType: string | undefined) {
`node ./node_modules/react-native/cli.js bundle \
--platform android \
--dev false \
--entry-file index.js \
--entry-file ${getAndroidIndexJsPath()} \
--bundle-output ${bundleOutput} \
--assets-dest ${resOutput}`,
{ cwd: getProjectRootDir() },
Expand Down
2 changes: 1 addition & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export default class Build extends Command {
logger.info('Building android');
await buildAndroid(buildFlavor, incremental, release);
}
logger.info(`Build finished in ${(performance.now() - start) / 1000} seconds`);
logger.info(`Build finished in ${((performance.now() - start) / 1000).toFixed(1)} seconds`);
}
}

0 comments on commit 65765a0

Please sign in to comment.