Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function copySkin(sdk: SDK, skin: string, skinpath: string): Promise {
const debug = Debug(`${modulePrefix}:${copySkin.name}`);
const skinsrc = pathlib.resolve(ASSETS_PATH, 'android', 'skins', skin);
const stat = await statSafe(skinsrc);
if (stat && stat.isDirectory()) {
debug('Copying skin from %s to %s', skinsrc, skinpath);
try {
return await copy(skinsrc, skinpath);
} catch (e) {
debug('Error while copying skin: %O', e);
}
}
throw new AVDException(`${skinpath} is an invalid skin.`, ERR_INVALID_SKIN);
}
export async function validateSkin(sdk: SDK, skin: string, skinpath: string): Promise {
const debug = Debug(`${modulePrefix}:${validateSkin.name}`);
const p = pathlib.join(skinpath, 'layout');
debug('Checking skin layout file: %s', p);
const stat = await statSafe(p);
if (stat && stat.isFile()) {
return;
}
await copySkin(sdk, skin, skinpath);
}
const platforms = await filter(contents, async file => {
const stat = await statSafe(path.join(platformsDir, file));
return !file.startsWith('.') && typeof stat !== 'undefined' && stat.isDirectory();
});
export async function validateSystemImagePath(sdk: SDK, sysdir: string): Promise {
const debug = Debug(`${modulePrefix}:${validateSystemImagePath.name}`);
const p = pathlib.join(sdk.root, sysdir, 'package.xml');
debug('Checking package.xml file: %s', p);
const stat = await statSafe(p);
if (!stat || !stat.isFile()) {
throw new AVDException(`${p} is an invalid system image package.`, ERR_INVALID_SYSTEM_IMAGE);
}
}