UNPKG

@codeenzyme/csv-json-cli

Version:

A command line utility for converting csv to/from json

53 lines (41 loc) 978 B
const fs = require('fs'); const chalk = require('chalk'); var packageFile = null; try { packageFile = fs.readFileSync("./package.json", "utf-8"); } catch (error) { packageFile = JSON.stringify({ version: "0.0.1-alpha04" }); } const package = JSON.parse(packageFile); // console.log(package); const logger = { success: function(str) { console.log(chalk.bold.green(str)); }, info: function(str) { console.log(chalk.bold.blue(str)); }, debug: function(str) { console.log(str); }, warn: function(str) { console.log(chalk.yellowBright.italic(str)) }, error: function(str) { console.log(chalk.red.bold(str)); } }; function checkIfPathExists(path) { return fs.existsSync(path); } function checkIfPathIsFile(path) { return checkIfPathExists && fs.lstatSync(path).isFile(); } module.exports = { package, logger, checkIfPathExists, checkIfPathIsFile };