UNPKG

365 BJavaScriptView Raw
1import path from 'path'
2
3let EXTENSIONS = ['view.blocks', 'logic.js', 'react.js']
4
5export default function getViewIdFromFile(file) {
6 let extension = EXTENSIONS.find(item => file.endsWith(item))
7
8 if (!extension) {
9 throw new Error(
10 `Can't recognise the extension of "${file}" to get a view's id.`
11 )
12 }
13
14 return path.basename(path.dirname(file))
15}