loadLocalPreset.js 391 B

12345678910111213
  1. const fs = require('fs-extra')
  2. const loadPresetFromDir = require('./loadPresetFromDir')
  3. module.exports = async function loadLocalPreset (path) {
  4. const stats = fs.statSync(path)
  5. if (stats.isFile()) {
  6. return await fs.readJson(path)
  7. } else if (stats.isDirectory()) {
  8. return await loadPresetFromDir(path)
  9. } else {
  10. throw new Error(`Invalid local preset path: ${path}`)
  11. }
  12. }