@mieweb/wikigdrive
Version:
Google Drive to MarkDown synchronization
26 lines (25 loc) • 905 B
JavaScript
export function fileNameToExt(fileName) {
const idx = fileName.lastIndexOf('.');
if (idx > -1) {
return fileName.substring(idx + 1);
}
return 'bin';
}
export function getFileDir(filePath) {
const parts = filePath.split('/');
if (parts.length < 2) {
return '/';
}
parts.pop();
return parts.join('/');
}
export async function removeMarkDownsAndImages(removePath, localFilesService) {
await localFilesService.remove(removePath);
const imagesPath = removePath.replace(/.md$/, '.assets');
if (removePath !== imagesPath) {
await localFilesService.remove(imagesPath);
}
}
export async function getContentFileService(transformedFileSystem, userConfigService) {
return userConfigService.config.transform_subdir ? await transformedFileSystem.getSubFileService(userConfigService.config.transform_subdir, '/') : transformedFileSystem;
}