♻️(tokens) migrate to Commander 12.0.0
Commander changed the way they throw errors and our implementations was causing issue with tests.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { program } from "commander";
|
import { ThemeGeneratorProgram } from "ThemeGenerator";
|
||||||
|
|
||||||
export const workPath = () => {
|
export const workPath = () => {
|
||||||
return program.opts().workingDir ?? process.cwd();
|
return ThemeGeneratorProgram.instance.opts().workingDir ?? process.cwd();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { program } from "commander";
|
import { Command } from "commander";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import figlet from "figlet";
|
import figlet from "figlet";
|
||||||
import { getConfig } from "ConfigLoader";
|
import { getConfig } from "ConfigLoader";
|
||||||
@@ -7,7 +7,7 @@ import { workPath } from "Paths";
|
|||||||
import { Generators } from "Generators";
|
import { Generators } from "Generators";
|
||||||
|
|
||||||
export const buildTheme = async () => {
|
export const buildTheme = async () => {
|
||||||
const options = program.opts();
|
const options = ThemeGeneratorProgram.instance.opts();
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const tokens = tokensGenerator(config);
|
const tokens = tokensGenerator(config);
|
||||||
const { generators } = options;
|
const { generators } = options;
|
||||||
@@ -26,6 +26,10 @@ export const buildTheme = async () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export class ThemeGeneratorProgram {
|
||||||
|
static instance: Command;
|
||||||
|
}
|
||||||
|
|
||||||
export const run = async (args: string[]) => {
|
export const run = async (args: string[]) => {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.red(figlet.textSync("Cunningham", { horizontalLayout: "full" })),
|
chalk.red(figlet.textSync("Cunningham", { horizontalLayout: "full" })),
|
||||||
@@ -35,7 +39,8 @@ export const run = async (args: string[]) => {
|
|||||||
return value.split(",");
|
return value.split(",");
|
||||||
};
|
};
|
||||||
|
|
||||||
program
|
ThemeGeneratorProgram.instance = new Command();
|
||||||
|
ThemeGeneratorProgram.instance
|
||||||
.description("Cunningham's CLI tool.")
|
.description("Cunningham's CLI tool.")
|
||||||
.option(
|
.option(
|
||||||
"-s, --selector <selector>",
|
"-s, --selector <selector>",
|
||||||
|
|||||||
Reference in New Issue
Block a user