You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
/**
|
|
* resolve action class
|
|
*
|
|
* @author Björn Hase <me@herr-hase.wtf>
|
|
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
|
|
* @link https://git.node001.net/HerrHase/signpost.git
|
|
*
|
|
*/
|
|
function resolveActionClass(className) {
|
|
|
|
let classPath = path.join(process.env.APP_BASE_DIR, 'resources/actions/' + className + '.js')
|
|
let result = undefined
|
|
|
|
if (fs.existsSync(classPath)) {
|
|
result = classPath
|
|
}
|
|
|
|
if (!result) {
|
|
throw new Error('Action Class ' + className + ' / ' + classPath + ' not found!')
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
/**
|
|
* resolve schema
|
|
*
|
|
* @author Björn Hase <me@herr-hase.wtf>
|
|
* @link https://git.node001.net/HerrHase/signpost.git
|
|
*
|
|
*/
|
|
function resolveSchema(schemaName) {
|
|
|
|
let schemaPath = path.join(process.env.APP_BASE_DIR, 'resources/schemas/' + schemaName + '.json')
|
|
let result = undefined
|
|
|
|
if (fs.existsSync(schemaPath)) {
|
|
result = schemaPath
|
|
}
|
|
|
|
if (!result) {
|
|
throw new Error('Schema ' + schemaName + ' / ' + schemaPath + ' not found!')
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
export {
|
|
resolveActionClass,
|
|
resolveSchema
|
|
}
|