chore: cleanup

This commit is contained in:
Igor Randjelovic
2020-12-07 15:01:17 +01:00
parent 2f39cf5ed6
commit d21776079f
15 changed files with 132 additions and 112 deletions

View File

@@ -1,4 +1,4 @@
import { INativeScriptPlatform } from '.';
import { INativeScriptPlatform } from "../helpers/platform";
function getDistPath() {
return `platforms/android/app/src/main/assets/app`;

View File

@@ -1,47 +0,0 @@
import { error } from "../helpers/log";
import { env, Platform } from "../";
import AndroidPlatform from "./android";
import iOSPlatform from "./ios";
export interface INativeScriptPlatform {
getEntryPath?(): string;
getDistPath?(): string
}
const platforms = {
android: AndroidPlatform,
ios: iOSPlatform,
}
export function addPlatform(name: string, platform: INativeScriptPlatform) {
console.log('adding platform', name, platform)
platforms[name] = platform;
}
export function getPlatform(): INativeScriptPlatform {
return platforms[getPlatformName()]
}
export function getPlatformName(): Platform {
if (env?.android) {
return 'android';
}
if (env?.ios) {
return 'ios';
}
// support custom platforms
if(env?.platform) {
return env.platform;
}
throw error(`
You need to provide a target platform!
Available platforms: ${Object.keys(platforms).join(', ')}
Use --env=platform=<platform> or --env=android, --env=ios to specify the target platform.
`);
}

View File

@@ -1,7 +1,7 @@
import { basename } from "path";
import { INativeScriptPlatform } from "../helpers/platform";
import { getProjectRootPath } from "../helpers/project";
import { INativeScriptPlatform } from '.';
function getDistPath() {
const appName = basename(getProjectRootPath());