egg-born-module-a-base-sync
Advanced tools
Comparing version 1.2.14 to 1.2.15
@@ -77,2 +77,5 @@ // eslint-disable-next-line | ||
// public dir | ||
config.publicDir = ''; | ||
// comment | ||
@@ -79,0 +82,0 @@ config.comment = { |
@@ -0,1 +1,5 @@ | ||
const path = require('path'); | ||
const require3 = require('require3'); | ||
const fse = require3('fs-extra'); | ||
const _modulesLocales = {}; | ||
@@ -37,2 +41,28 @@ const _locales = {}; | ||
// get forward url | ||
getForwardUrl(path) { | ||
const prefix = (ctx.app.meta.isTest || ctx.app.meta.isLocal) ? ctx.app.config.static.prefix : '/public/'; | ||
return `${prefix}${ctx.instance.id}/${path}`; | ||
} | ||
// get root path | ||
async getRootPath() { | ||
if (ctx.app.meta.isTest || ctx.app.meta.isLocal) { | ||
return ctx.app.config.static.dir; | ||
} | ||
const dir = ctx.config.module(moduleInfo.relativeName).publicDir || path.join(require('os').homedir(), 'cabloy', ctx.app.name, 'public'); | ||
await fse.ensureDir(dir); | ||
return dir; | ||
} | ||
// get path | ||
async getPath(subdir, ensure) { | ||
const rootPath = await this.getRootPath(); | ||
const dir = path.join(rootPath, ctx.instance.id.toString(), subdir || ''); | ||
if (ensure) { | ||
await fse.ensureDir(dir); | ||
} | ||
return dir; | ||
} | ||
modules() { | ||
@@ -39,0 +69,0 @@ if (!_modulesLocales[ctx.locale]) { |
{ | ||
"name": "egg-born-module-a-base-sync", | ||
"version": "1.2.14", | ||
"version": "1.2.15", | ||
"title": "Base", | ||
@@ -5,0 +5,0 @@ "eggBornModule": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
973510
14289