fec-builder
Version:
通用的前端构建工具,屏蔽业务无关的细节配置,开箱即用
60 lines (59 loc) • 2.06 kB
JavaScript
/**
* @file paths
* @author nighca <nighca@live.cn>
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTestDistPath = exports.getDistPath = exports.getStaticPath = exports.getSrcPath = exports.setBuildConfigFilePath = exports.getBuildConfigFilePath = exports.abs = exports.setBuildRoot = exports.getBuildRoot = void 0;
const path_1 = __importDefault(require("path"));
const logger_1 = __importDefault(require("./logger"));
let buildRoot = process.env.BUILD_ROOT || process.cwd();
function getBuildRoot() {
return buildRoot;
}
exports.getBuildRoot = getBuildRoot;
function setBuildRoot(target) {
const resolved = path_1.default.resolve(target);
logger_1.default.debug(`set build root: ${target} (${resolved})`);
buildRoot = resolved;
}
exports.setBuildRoot = setBuildRoot;
/** get absolute path with given path relative to build root */
function abs(p) {
return path_1.default.resolve(buildRoot, p);
}
exports.abs = abs;
let buildConfigFilePath = process.env.BUILD_CONFIG_FILE || null;
/** get build config file path */
function getBuildConfigFilePath() {
return buildConfigFilePath;
}
exports.getBuildConfigFilePath = getBuildConfigFilePath;
/** set build config file path */
function setBuildConfigFilePath(target) {
buildConfigFilePath = path_1.default.resolve(target);
}
exports.setBuildConfigFilePath = setBuildConfigFilePath;
/** get src path */
function getSrcPath(conf) {
return abs(conf.srcDir);
}
exports.getSrcPath = getSrcPath;
/** get static path */
function getStaticPath(conf) {
return abs(conf.staticDir);
}
exports.getStaticPath = getStaticPath;
/** get dist path */
function getDistPath(conf) {
return abs(conf.distDir);
}
exports.getDistPath = getDistPath;
/** get test dist path */
function getTestDistPath(conf) {
return path_1.default.join(getDistPath(conf), '.test');
}
exports.getTestDistPath = getTestDistPath;
;