UNPKG

@gqlts/cli

Version:

Generate a client sdk from your GraphQl API

34 lines 2 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.readFilesAndConcat = exports.writeFileToPath = exports.readFileFromPath = exports.requireModuleFromPath = void 0; exports.ensurePath = ensurePath; const fs_1 = require("fs"); const mkdirp_1 = require("mkdirp"); const path_1 = require("path"); const rimraf_1 = require("rimraf"); function ensurePath(path_2) { return __awaiter(this, arguments, void 0, function* (path, clear = false) { if (clear) { (0, rimraf_1.rimrafSync)((0, path_1.resolve)(...path)); } (0, mkdirp_1.mkdirpSync)((0, path_1.resolve)(...path)); }); } const requireModuleFromPath = (path) => require((0, path_1.resolve)(...path)); exports.requireModuleFromPath = requireModuleFromPath; const readFileFromPath = (path) => fs_1.promises.readFile((0, path_1.resolve)(...path)).then((b) => b.toString()); exports.readFileFromPath = readFileFromPath; const writeFileToPath = (path, content) => fs_1.promises.writeFile((0, path_1.resolve)(...path), content); exports.writeFileToPath = writeFileToPath; const readFilesAndConcat = (files) => Promise.all(files.map((file) => (0, exports.readFileFromPath)([file]))).then((contents) => contents.join('\n')); exports.readFilesAndConcat = readFilesAndConcat; //# sourceMappingURL=files.js.map