@fesjs/compiler
Version:
@fesjs/compiler
41 lines (39 loc) • 1.24 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getServicePaths;
var _path = require("path");
var _fs = require("fs");
var _utils = require("@fesjs/utils");
/**
* @copy 该文件代码大部分出自 umi,有需要请参考:
* https://github.com/umijs/umi/tree/master/packages/core
*/
function isDirectoryAndExist(path) {
return (0, _fs.existsSync)(path) && (0, _fs.statSync)(path).isDirectory();
}
function normalizeWithWinPath(obj) {
return _utils.lodash.mapValues(obj, value => (0, _utils.winPath)(value));
}
function getServicePaths({
cwd,
config,
env
}) {
let absSrcPath = cwd;
if (isDirectoryAndExist((0, _path.join)(cwd, 'src'))) {
absSrcPath = (0, _path.join)(cwd, 'src');
}
const absPagesPath = config.singular ? (0, _path.join)(absSrcPath, 'page') : (0, _path.join)(absSrcPath, 'pages');
const tmpDir = ['.fes', env !== 'development' && env].filter(Boolean).join('-');
return normalizeWithWinPath({
tmpDir,
cwd,
absNodeModulesPath: (0, _path.join)(cwd, 'node_modules'),
absOutputPath: (0, _path.join)(cwd, config.outputPath || './dist'),
absSrcPath,
absPagesPath,
absTmpPath: (0, _path.join)(absSrcPath, tmpDir)
});
}
;