UNPKG

fh-serverless

Version:

A Node.js CLI for optimizing and generating configuration files for Serverless projects

28 lines (27 loc) 1.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const generate_1 = require("./generate"); const promises_1 = require("node:fs/promises"); const path_1 = __importDefault(require("path")); const currentDir = path_1.default.resolve('./'); const program = new commander_1.Command(); function checkPath(projectPath) { return (0, promises_1.access)(projectPath) .then(() => projectPath) .catch(() => { console.error(`Path ${projectPath} does not exist`); throw new Error('Project folder not found'); }); } program .command('generate [path]') .description('Create the configuration file serverless.yml') .action(async (path) => { const newPath = (await checkPath(path ?? currentDir)); return (0, generate_1.generate)(newPath); }); program.parse(process.argv);