1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path = require("path");
|
4 | exports.default = (ctx) => {
|
5 | ctx.registerMethod('writeFileToDist', ({ filePath, content }) => {
|
6 | const { outputPath } = ctx.paths;
|
7 | const { printLog, processTypeEnum, fs } = ctx.helper;
|
8 | if (path.isAbsolute(filePath)) {
|
9 | printLog(processTypeEnum.ERROR, `ctx.writeFileToDist 不能接受绝对路径`);
|
10 | return;
|
11 | }
|
12 | const absFilePath = path.join(outputPath, filePath);
|
13 | fs.ensureDirSync(path.dirname(absFilePath));
|
14 | fs.writeFileSync(absFilePath, content);
|
15 | });
|
16 | };
|