diff --git a/packages/tokens/src/bin/Paths.ts b/packages/tokens/src/bin/Paths.ts index c060dea..1bc52e6 100644 --- a/packages/tokens/src/bin/Paths.ts +++ b/packages/tokens/src/bin/Paths.ts @@ -1,3 +1,5 @@ +import { program } from "commander"; + export const workPath = () => { - return process.cwd(); + return program.opts().workingDir ?? process.cwd(); }; diff --git a/packages/tokens/src/bin/ThemeGenerator.ts b/packages/tokens/src/bin/ThemeGenerator.ts index 3f00757..d93cddf 100644 --- a/packages/tokens/src/bin/ThemeGenerator.ts +++ b/packages/tokens/src/bin/ThemeGenerator.ts @@ -3,8 +3,8 @@ import chalk from "chalk"; import figlet from "figlet"; import { getConfig } from "ConfigLoader"; import { tokensGenerator } from "TokensGenerator"; -import { workPath } from "Paths"; import { Generators } from "Generators"; +import { workPath } from "Paths"; export const buildTheme = async () => { const options = program.opts(); @@ -17,7 +17,7 @@ export const buildTheme = async () => { throw new Error('The generator "' + generator + '" does not exist.'); } return Generators[generator](tokens, { - path: options.output, + path: options.output ?? workPath(), selector: options.selector, }); }) @@ -35,16 +35,19 @@ export const run = async (args: string[]) => { program .description("Cunningham's CLI tool.") - .option( - "-o, --output ", - "Specify the output dir of generated files.", - workPath() - ) .option( "-s, --selector ", "Specify the css root selector element.", ":root" ) + .option( + "-cwd, --working-dir ", + "Specify the working dir ( you might not need this )." + ) + .option( + "-o, --output ", + "Specify the output dir of generated files." + ) .requiredOption( "-g, --generators ", "Specify the generators to use.",