diff --git a/package-lock.json b/package-lock.json index fcf15cf..b402d62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,17 @@ { "name": "convert-to-oklch", - "version": "1.0.0", + "version": "1.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "convert-to-oklch", - "version": "1.0.0", + "version": "1.0.8", "license": "MIT", "dependencies": { "colorjs.io": "^0.4.0", "commander": "^9.4.0", + "picocolors": "^1.0.0", "postcss": "^8.4.16" }, "bin": { @@ -18,6 +19,9 @@ }, "devDependencies": { "jest": "^28.1.3" + }, + "engines": { + "node": ">=16" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index cd944d1..d938f82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "convert-to-oklch", - "version": "1.0.8", + "version": "1.0.9", "description": "CLI tool that converts rgb(), rgba(), hex, hsl() and hsla() colors to oklch() in specified CSS files.", "main": "./src/index.js", "bin": { @@ -39,6 +39,7 @@ "dependencies": { "colorjs.io": "^0.4.0", "commander": "^9.4.0", + "picocolors": "^1.0.0", "postcss": "^8.4.16" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index aff4017..73c27b8 100755 --- a/src/index.js +++ b/src/index.js @@ -3,6 +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 plugin = require("./plugin"); program @@ -13,6 +14,11 @@ program .version(packageVersion); program.argument("", "path to css files").action(async (path) => { + if (!fs.existsSync(path)) { + console.error(pc.bgRed("File doesn't exist")); + process.exit(1); + } + const css = fs.readFileSync(path, "utf-8"); const result = await postcss([plugin]) @@ -20,9 +26,9 @@ program.argument("", "path to css files").action(async (path) => { .toString(); await fs.writeFile(path, result, (err) => { - if (err) console.error(err); + if (err) console.error(pc.bgRed(err)); - console.log("Done!"); + console.log(pc.bgGreen("Done!")); }); });