The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(cli): absolute path support for -d flag (#1756)

authored by

Emile Bangma and committed by
GitHub
57944059 59d5a0ed

+13 -4
+13 -4
quartz/cli/handlers.js
··· 34 34 } from "./constants.js" 35 35 36 36 /** 37 + * Resolve content directory path 38 + * @param contentPath path to resolve 39 + */ 40 + function resolveContentPath(contentPath) { 41 + if (path.isAbsolute(contentPath)) return path.relative(cwd, contentPath) 42 + return path.join(cwd, contentPath) 43 + } 44 + 45 + /** 37 46 * Handles `npx quartz create` 38 47 * @param {*} argv arguments for `create` 39 48 */ 40 49 export async function handleCreate(argv) { 41 50 console.log() 42 51 intro(chalk.bgGreen.black(` Quartz v${version} `)) 43 - const contentFolder = path.join(cwd, argv.directory) 52 + const contentFolder = resolveContentPath(argv.directory) 44 53 let setupStrategy = argv.strategy?.toLowerCase() 45 54 let linkResolutionStrategy = argv.links?.toLowerCase() 46 55 const sourceDirectory = argv.source ··· 450 459 * @param {*} argv arguments for `update` 451 460 */ 452 461 export async function handleUpdate(argv) { 453 - const contentFolder = path.join(cwd, argv.directory) 462 + const contentFolder = resolveContentPath(argv.directory) 454 463 console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`)) 455 464 console.log("Backing up your content") 456 465 execSync( ··· 502 511 * @param {*} argv arguments for `restore` 503 512 */ 504 513 export async function handleRestore(argv) { 505 - const contentFolder = path.join(cwd, argv.directory) 514 + const contentFolder = resolveContentPath(argv.directory) 506 515 await popContentFolder(contentFolder) 507 516 } 508 517 ··· 511 520 * @param {*} argv arguments for `sync` 512 521 */ 513 522 export async function handleSync(argv) { 514 - const contentFolder = path.join(cwd, argv.directory) 523 + const contentFolder = resolveContentPath(argv.directory) 515 524 console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`)) 516 525 console.log("Backing up your content") 517 526