wikibase-cli
Version:
A command-line interface to Wikibase
19 lines (17 loc) • 455 B
JavaScript
import { access } from 'node:fs/promises'
import { mkdirp } from 'mkdirp'
import getFolderPath from './get_folder_path.js'
export async function getCacheFolderPath (subfolder) {
const subfolderPath = getFolderPath('cache', subfolder)
try {
await access(subfolderPath)
return subfolderPath
} catch (err) {
if (err.code === 'ENOENT') {
await mkdirp(subfolderPath)
return subfolderPath
} else {
throw err
}
}
}