Skip to content

Commit

Permalink
Added a bunch of debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tmayoff committed Jul 10, 2024
1 parent 1e92784 commit 02785c2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 57 deletions.
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 0 additions & 53 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,59 +35,6 @@
# Disabling check here to work with build sandboxing.
doCheck = false;
};

biome = prev.rustPlatform.buildRustPackage rec {
pname = "biome";
version = "1.8.1";

src = prev.fetchFromGitHub {
owner = "biomejs";
repo = "biome";
rev = "cli/v${version}";
hash = "sha256-RR4yHrLeEHNLe0Nr8FHm+u+DFJihbibRax41Ss9HDV8=";
};

cargoHash = "sha256-xCA1kxt70lrCrPygMe98eF8RC/l47EnJPjLaXBccBRE=";

nativeBuildInputs = with prev; [
pkg-config
];

buildInputs = with prev;
[
libgit2
rust-jemalloc-sys
zlib
]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];

nativeCheckInputs = with prev; [
git
];

cargoBuildFlags = ["-p=biome_cli"];
cargoTestFlags =
cargoBuildFlags
++
# skip a broken test from v1.7.3 release
# this will be removed on the next version
["-- --skip=diagnostics::test::termination_diagnostic_size"];

env = {
BIOME_VERSION = version;
LIBGIT2_NO_VENDOR = 1;
};

preCheck = ''
# tests assume git repository
git init
# tests assume $BIOME_VERSION is unset
unset BIOME_VERSION
'';
};
})
];

Expand Down
7 changes: 7 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class Context {

async loadRecipes(file: TAbstractFile | undefined) {
const recipeFolderPath = get(this.settings).recipeDirectory;
if (this.debugMode()) {
console.debug("Recipe Folder:", recipeFolderPath);
}
const recipeFolder = this.app.vault.getFolderByPath(recipeFolderPath);
if (recipeFolder == null) {
console.error(`Failed to load recipes, can't access directory: ${recipeFolderPath}`);
Expand All @@ -55,4 +58,8 @@ export class Context {
this.recipes.set(r);
});
}

debugMode() {
return get(this.settings).debugMode;
}
}
Empty file removed src/recipe/get_ingredient_set.ts
Empty file.
16 changes: 16 additions & 0 deletions src/recipe/ingredients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export async function GetIngredients(ctx: Context, recipeFile: TFile) {
}

function parseIngredients(ctx: Context, content: string): Ingredient[] {
if (ctx.debugMode()) {
console.debug('Parsing ingredients as: RecipeMD');
}

const recipes: Ingredient[] = new Array();

const headerString = '# Ingredients';
Expand All @@ -77,6 +81,10 @@ function parseIngredients(ctx: Context, content: string): Ingredient[] {
}

function parseIngredientsRecipemd(ctx: Context, content: string): Ingredient[] {
if (ctx.debugMode()) {
console.debug('Parsing ingredients as: RecipeMD');
}

const recipes: Ingredient[] = new Array();
const ingredients = content.split('---')[1];

Expand Down Expand Up @@ -111,6 +119,10 @@ function ParseIngredient(ctx: Context, content: string): Ingredient {
};

if (doAdvancedParse) {
if (ctx.debugMode()) {
console.debug('Advanced parsing; original line:', content);
}

// ============================
// Special ingredient parsing
// =============================
Expand Down Expand Up @@ -153,6 +165,10 @@ function ParseIngredient(ctx: Context, content: string): Ingredient {
tingredient.description = singular(tingredient.description);
}

if (ctx.debugMode()) {
console.debug('Final ingredient output', tingredient, altIngredients);
}

return {
...tingredient,
...altIngredients,
Expand Down
3 changes: 3 additions & 0 deletions src/recipe/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export async function GetRecipes(ctx: Context, recipeDir: TFolder) {

for (const file of recipeDir.children) {
if (file instanceof TFile) {
if (ctx.debugMode()) {
console.debug("Parsing recipe:", file.path);
}
const recipe = new Recipe(file);
await recipe.fillIngredients(ctx);
recipes.push(recipe);
Expand Down

0 comments on commit 02785c2

Please sign in to comment.