27 lines
816 B
JavaScript
27 lines
816 B
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const path_1 = __importDefault(require("path"));
|
|
const fs_1 = __importDefault(require("../../utils/fs"));
|
|
/**
|
|
Write a file to the output folder
|
|
|
|
@param {Output} output
|
|
@param {string} filePath
|
|
@param {Buffer|String} content
|
|
@return {Promise}
|
|
*/
|
|
function writeFile(output, filePath, content) {
|
|
const rootFolder = output.getRoot();
|
|
filePath = path_1.default.join(rootFolder, filePath);
|
|
return fs_1.default
|
|
.ensureFile(filePath)
|
|
.then(() => {
|
|
return fs_1.default.writeFile(filePath, content);
|
|
})
|
|
.thenResolve(output);
|
|
}
|
|
exports.default = writeFile;
|