From 69457ec96426ee7d175ddc38d8f356f9111e6f6c Mon Sep 17 00:00:00 2001 From: Stephan Lo Date: Sat, 25 Oct 2025 09:40:44 +0200 Subject: [PATCH] feat(build): add automatic npm dependency management - Add deps:ensure-npm task to automatically install npm packages when needed - Configure build, serve, and test tasks to depend on npm dependencies - Use Task's sources/generates/status for intelligent dependency detection - Prevents build failures due to missing PostCSS and other npm packages - Improves developer experience by eliminating manual npm install steps --- Taskfile.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Taskfile.yml b/Taskfile.yml index 5592f19..acf0237 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,16 +13,22 @@ tasks: # Build tasks build: desc: Build Hugo site + deps: + - deps:ensure-npm cmds: - "{{.HUGO_CMD}} --gc --minify" build:dev: desc: Build Hugo site for development + deps: + - deps:ensure-npm cmds: - "{{.HUGO_CMD}}" serve: desc: Start Hugo dev server + deps: + - deps:ensure-npm cmds: - "{{.HUGO_CMD}} server" @@ -48,16 +54,22 @@ tasks: test:build: desc: Test Hugo build + deps: + - deps:ensure-npm cmds: - "{{.HUGO_CMD}} --gc --minify --logLevel info" test:markdown: desc: Lint markdown files + deps: + - deps:ensure-npm cmds: - "{{.NPM_CMD}} run test:markdown" test:html: desc: Validate HTML + deps: + - deps:ensure-npm cmds: - "{{.NPM_CMD}} run test:html" @@ -67,6 +79,18 @@ tasks: - htmltest # Development tasks + deps:ensure-npm: + desc: Ensure npm dependencies are installed + sources: + - package.json + - package-lock.json + generates: + - node_modules/.package-lock.json + cmds: + - "{{.NPM_CMD}} install" + status: + - test -d node_modules + deps:install: desc: Install all dependencies cmds: