util.js 634 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
const path = require('path')

const {
  normalizePath
} = require('@dcloudio/uni-cli-shared')

const {
  getPlatformExts
} = require('../shared')

const templateExt = getPlatformExts().template

const SLOTS_OUTPUT_PATH = '/[root]common/slots'

function getRelativePath (from, to) {
  let relativePath = path.relative(from, to)
  if (relativePath.indexOf('.') !== 0) {
    relativePath = './' + relativePath
  }
  return normalizePath(relativePath)
}

function getSlotsPath (root) {
  return SLOTS_OUTPUT_PATH.replace('[root]', root) + templateExt
}

module.exports = {
  getSlotsPath,
  getRelativePath
}