mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: additional base setup
This commit is contained in:
@@ -1,27 +1,40 @@
|
||||
import { existsSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { IWebpackEnv } from '@nativescript/webpack';
|
||||
|
||||
import { existsSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
export function getDistPath(env: IWebpackEnv) {
|
||||
if (env.ios) {
|
||||
return `platforms/ios/[todo]/app`;
|
||||
}
|
||||
|
||||
if (env.android) {
|
||||
return `platforms/android/app/src/main/assets/app`;
|
||||
}
|
||||
|
||||
// todo: additional platforms
|
||||
// perhaps we could combine platform specifics into "plugins"
|
||||
// 3rd party platforms would be treated the same
|
||||
}
|
||||
|
||||
export function getPackageJson(projectDir: string) {
|
||||
const packageJsonPath = getPackageJsonPath(projectDir);
|
||||
const result = readJsonFile(packageJsonPath);
|
||||
const packageJsonPath = getPackageJsonPath(projectDir);
|
||||
const result = readJsonFile(packageJsonPath);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
export function readJsonFile(filePath:string) {
|
||||
return require(filePath) as {
|
||||
main:string
|
||||
// to be extended?
|
||||
};
|
||||
export function readJsonFile(filePath: string) {
|
||||
return require(filePath) as {
|
||||
main: string;
|
||||
// to be extended?
|
||||
};
|
||||
}
|
||||
|
||||
export function getPackageJsonPath (projectDir: string) {
|
||||
const packagePath = resolve(projectDir, "package.json");
|
||||
if (existsSync(packagePath)) {
|
||||
return packagePath;
|
||||
} else {
|
||||
return getPackageJsonPath(resolve(projectDir, '..'));
|
||||
}
|
||||
|
||||
}
|
||||
export function getPackageJsonPath(projectDir: string) {
|
||||
const packagePath = resolve(projectDir, 'package.json');
|
||||
if (existsSync(packagePath)) {
|
||||
return packagePath;
|
||||
} else {
|
||||
return getPackageJsonPath(resolve(projectDir, '..'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user