Skip to content

Commit

Permalink
fix multiple files handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetrakov committed Aug 30, 2022
1 parent 8bc5a16 commit 653a93e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "convert-to-oklch",
"version": "1.0.9",
"version": "1.1.0",
"description": "CLI tool that converts rgb(), rgba(), hex, hsl() and hsla() colors to oklch() in specified CSS files.",
"main": "./src/index.js",
"bin": {
Expand Down
19 changes: 13 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { program } = require("commander");
const packageVersion = require("../package.json").version;
const postcss = require("postcss");
const fs = require("fs");
const pc = require("picocolors")
const pc = require("picocolors");
const plugin = require("./plugin");

program
Expand All @@ -13,9 +13,14 @@ program
)
.version(packageVersion);

program.argument("<path>", "path to css files").action(async (path) => {
program.argument("<path>", "path to css files");
program.parse();

const { args } = program;

const convertColors = async (path) => {
if (!fs.existsSync(path)) {
console.error(pc.bgRed("File doesn't exist"));
console.error(pc.bgRed(pc.bgBlack("File doesn't exist")));
process.exit(1);
}

Expand All @@ -28,8 +33,10 @@ program.argument("<path>", "path to css files").action(async (path) => {
await fs.writeFile(path, result, (err) => {
if (err) console.error(pc.bgRed(err));

console.log(pc.bgGreen("Done!"));
console.log(pc.bgGreen(pc.black("Done! " + path)));
});
});
};

program.parse();
for (const path of args) {
convertColors(path);
}

0 comments on commit 653a93e

Please sign in to comment.