UNPKG

@microsoft.azure/autorest.incubator

Version:
41 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const aio = require("@microsoft.azure/async-io"); const path_1 = require("path"); const dictionary_1 = require("../common/dictionary"); function getAllPropertyNames(obj) { const props = new Array(); do { Object.getOwnPropertyNames(obj).forEach(function (prop) { if (props.indexOf(prop) === -1) { props.push(prop); } }); } while (obj = Object.getPrototypeOf(obj)); return props; } function fail(text) { throw new Error(text); } exports.fail = fail; async function copyResources(sourceFolder, fileWriter) { const done = new Array(); try { const files = await aio.readdir(sourceFolder); for (const file of dictionary_1.values(files)) { const fullPath = path_1.join(sourceFolder, file); if (await aio.isDirectory(fullPath)) { done.push(copyResources(fullPath, async (f, c) => fileWriter(`${file}/${f}`, c))); continue; } if (await aio.isFile(fullPath)) { done.push(aio.readFile(fullPath).then(async (content) => fileWriter(file, content))); } } } catch (_a) { } await Promise.all(done); } exports.copyResources = copyResources; //# sourceMappingURL=utility.js.map