Remove camelcase dep, roll my own

This commit is contained in:
Will Boyd
2025-02-06 14:12:47 -05:00
parent df5731985d
commit 66798a044f
4 changed files with 152 additions and 109 deletions
+4 -5
View File
@@ -1,4 +1,3 @@
import camelcase from 'camelcase';
import chalk from 'chalk';
import * as commander from 'commander';
import * as luxon from 'luxon';
@@ -29,7 +28,7 @@ export async function getConfig() {
// run wizard for questions with prompts that were not answered via the command line
const wizardQuestions = questions.all.filter((question) => {
return question.prompt && !(camelcase(question.name) in commandLineAnswers);
return question.prompt && !(shared.camelCase(question.name) in commandLineAnswers);
});
wizardAnswers = await getWizardAnswers(wizardQuestions, commandLineAnswers);
} else {
@@ -74,7 +73,7 @@ function getCommandLineAnswers(questions) {
continue;
}
const question = questions.find((question) => camelcase(question.name) === key);
const question = questions.find((question) => shared.camelCase(question.name) === key);
if (answers.wizard && question.prompt) {
// remove this default answer, allowing the wizard to ask about it later
delete answers[key];
@@ -93,7 +92,7 @@ function getCommandLineAnswers(questions) {
export async function getWizardAnswers(questions, commandLineAnswers) {
const answers = {};
for (const question of questions) {
let answerKey = camelcase(question.name);
let answerKey = shared.camelCase(question.name);
let normalizedAnswer; // holds normalized answer value potentially returned during validation
const promptConfig = {
@@ -143,7 +142,7 @@ export async function getWizardAnswers(questions, commandLineAnswers) {
}
function normalize(value, type, onError) {
const normalizer = normalizers[camelcase(type)];
const normalizer = normalizers[shared.camelCase(type)];
if (!normalizer) {
return value;
}
+4
View File
@@ -1,5 +1,9 @@
import path from 'path';
export function camelCase(str) {
return str.replace(/-(.)/g, (match) => match[1].toUpperCase());
}
export function buildPostPath(outputDir, type, date, slug, config) {
// start with base output dir and post type
const pathSegments = [outputDir, type];