chore: add JSDocs

This commit is contained in:
Igor Randjelovic
2020-12-08 12:07:42 +01:00
parent d21776079f
commit de5f67f7c8
10 changed files with 131 additions and 0 deletions

View File

@ -22,15 +22,27 @@ const platforms: {
ios: iOSPlatform,
};
/**
* Utility to register a new supported platform.
*
* @param {string} name The name of the platform (eg. web, desktop)
* @param platform A platform definition of the platform specifics
*/
export function addPlatform(name: string, platform: INativeScriptPlatform) {
console.log('adding platform', name, platform);
platforms[name] = platform;
}
/**
* Utility to get the currently targeted platform definition
*/
export function getPlatform(): INativeScriptPlatform {
return platforms[getPlatformName()];
}
/**
* Utility to get the currently targeted platform name
*/
export function getPlatformName(): Platform {
if (env?.android) {
return 'android';
@ -62,6 +74,9 @@ export function getPlatformName(): Platform {
`);
}
/**
* Utility to get the entry file path for the currently targeted platform
*/
export function getEntryPath() {
const platform = getPlatform();
@ -76,10 +91,16 @@ export function getEntryPath() {
return resolve(getProjectRootPath(), packageJson.main);
}
/**
* Utility to get the entry file directory path for the currently targeted platform
*/
export function getEntryDirPath() {
return dirname(getEntryPath());
}
/**
* Utility to get the dist file path for the currently targeted platform
*/
export function getDistPath() {
const platform = getPlatform();
@ -92,6 +113,9 @@ export function getDistPath() {
return `platforms/${getPlatformName()}/dist`;
}
/**
* Utility to get the absolute dist file path for the currently targeted platform
*/
export function getAbsoluteDistPath() {
return resolve(getProjectRootPath(), getDistPath());
}