mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: workiing on base
This commit is contained in:
27
packages/webpack5/src/helpers/projectHelpers.ts
Normal file
27
packages/webpack5/src/helpers/projectHelpers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import { existsSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
|
||||
export function getPackageJson(projectDir: string) {
|
||||
const packageJsonPath = getPackageJsonPath(projectDir);
|
||||
const result = readJsonFile(packageJsonPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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, '..'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user