UNPKG

bicep-assets

Version:
53 lines (52 loc) 2.17 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CopyBuildPlugin = exports.CopyBuildCommand = void 0; const promises_1 = require("fs/promises"); const path_1 = require("path"); class CopyBuildCommand { constructor(name, path, plugin) { this.name = name; this.path = path; this.plugin = plugin; } buildInFolder(folder) { return __awaiter(this, void 0, void 0, function* () { const stats = yield (0, promises_1.stat)(this.path); if (stats.isDirectory()) { yield (0, promises_1.cp)(this.path, folder, { recursive: true, }); return; } else if (stats.isFile()) { const target = (0, path_1.join)(folder, (0, path_1.basename)(this.path)); yield (0, promises_1.cp)(this.path, target); // eslint-disable-next-line consistent-return return target; } else { throw new Error(`Invalid path: ${this.path}`); } }); } } exports.CopyBuildCommand = CopyBuildCommand; class CopyBuildPlugin { generateBuildCommands(configuration) { return __awaiter(this, void 0, void 0, function* () { return [ new CopyBuildCommand(configuration.name, configuration.path, this), ]; }); } } exports.CopyBuildPlugin = CopyBuildPlugin;