UNPKG

spring-boot-cli

Version:
34 lines (33 loc) 1.11 kB
import fs from "fs-extra"; import chalk from "chalk"; import { globSync } from "glob"; const readFile = (filePath) => { if (!fs.existsSync(filePath)) { console.error(chalk.red(`The file ${filePath} does not exist!`)); process.exit(1); } return fs.readFileSync(filePath, "utf-8"); }; const writeFile = (filePath, content) => { fs.writeFileSync(filePath, content); }; const createFolder = (folderPath, failIfExist = true) => { if (failIfExist && fs.existsSync(folderPath)) { console.error(chalk.red(`The directory ${folderPath} already exists!`)); process.exit(1); } fs.mkdirSync(folderPath, { recursive: true }); }; const getJavaFiles = (pattern) => { return globSync(pattern); }; const copyFiles = (source, destination) => { fs.copySync(source, destination, { preserveTimestamps: false }); }; const deleteFolder = (folderPath) => { fs.removeSync(folderPath); }; const renameFile = (oldPath, newPath) => { fs.renameSync(oldPath, newPath); }; export { readFile, writeFile, createFolder, getJavaFiles, copyFiles, deleteFolder, renameFile };