Skip to content

Commit

Permalink
Merge pull request #47 from utilitycss/fix/remove-console-log
Browse files Browse the repository at this point in the history
fix: remove console log
  • Loading branch information
axyz authored Mar 19, 2021
2 parents 57eeb22 + b60c316 commit d0cc380
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>",
"repository": "utilitycss/utility",
Expand Down
11 changes: 7 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)));
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/save-file.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -18,15 +21,15 @@ export default async function saveFile({
}: SaveFile): Promise<void> {
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, {
recursive: true,
});
}
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"] });
}
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d0cc380

Please sign in to comment.