diff --git a/package.json b/package.json index dde9acd..6e97aa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@utilitycss/utility", - "version": "1.0.3", + "version": "1.0.4", "description": "Generator for Utility CSS frameworks", "author": "Andrea Moretti (@axyz) ", "repository": "utilitycss/utility", diff --git a/src/cli.ts b/src/cli.ts index adc40ad..4f9811c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,4 +1,8 @@ #!/usr/bin/env ts-node + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const debug = require("debug")("utility:cli"); + import program from "commander"; import postcss from "postcss"; import chalk from "chalk"; @@ -35,8 +39,7 @@ program "utf8" ); fs.writeFileSync(configFile, output); - // eslint-disable-next-line no-console - console.log(chalk.green(`Generated config file: ${configFile}`)); + debug(`Generated config file: ${configFile}`); }); program @@ -68,13 +71,13 @@ program } // eslint-disable-next-line no-console - console.log(chalk.blue("Building CSS bundle...")); + debug("Building CSS bundle..."); postcss([builder(config)]) .process(input) .then(async (result) => { await write(result.css); // eslint-disable-next-line no-console - console.log(chalk.green("Success!")); + debug("Success!"); }) // eslint-disable-next-line no-console .catch((e) => console.error(chalk.red(e))); diff --git a/src/helpers/save-file.ts b/src/helpers/save-file.ts index 5d488e8..cb1dca1 100644 --- a/src/helpers/save-file.ts +++ b/src/helpers/save-file.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const debug = require("debug")("utility:save-file"); + import fs from "fs"; import { promises as fsAsync } from "fs"; import open from "open"; @@ -18,7 +21,7 @@ export default async function saveFile({ }: SaveFile): Promise { if (content === undefined) { console.error(chalk.red("The content of the file should not be empty")); - process.exit(0); + process.exit(1); } if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { @@ -26,7 +29,7 @@ export default async function saveFile({ }); } await fsAsync.writeFile(filePath, content); - console.log(chalk.blue(`Document was created : ${filePath}`)); + debug(`Document was created : ${filePath}`); if (openFile) { open(filePath, { app: ["google-chrome", "--incognito"] }); } diff --git a/src/index.ts b/src/index.ts index 031b0c0..bf631b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const debug = require("debug")("utility"); + import fs from "fs"; import chalk from "chalk"; import path from "path"; @@ -68,10 +71,8 @@ function utilityPlugin(config?: PluginConfig) { */ if (moduleName && !fs.existsSync(modulePath)) { // eslint-disable-next-line no-console - console.log( - chalk.red(`Module => ${moduleName} : is not supported`) - ); - process.exit(-1); + debug(`Module => ${moduleName} : is not supported`); + process.exit(1); } // eslint-disable-next-line @typescript-eslint/no-var-requires const moduleFunction = require(modulePath).default;