pre-commit

main
Yanick Champoux 2023-01-14 13:42:43 -05:00
parent 6bbba634c8
commit efd596410b
4 changed files with 33 additions and 1 deletions

14
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,14 @@
#exclude: static/fontawesome|^build
default_stages:
- merge-commit
- push
repos:
- repo: local
hooks:
- id: lint
name: lint
entry: task lint:fix --
language: system
files: ''

View File

@ -4,6 +4,8 @@ version: '3'
vars:
GREETING: Hello, World!
FILES:
sh: git diff-ls --diff-filter=d main | perl -pe's/\n/ /'
tasks:
build: vite build
@ -13,3 +15,14 @@ tasks:
cmds:
- echo "{{.GREETING}}"
silent: true
lint:fix:
cmds:
- npx prettier --write {{.CLI_ARGS | default .FILES }}
# - npx eslint --fix --quiet {{.CLI_ARGS | default .FILES }}
integrate:
cmds:
- git is-clean
- task: lint:fix
- task: test
- git co main
- git weld -

View File

@ -11,6 +11,7 @@ const seedCampaign = {
export function genApi(options = {}) {
// if (options.local) MyPouch.plugin(pouchMem);
if (options.pouch) options.pouch(PouchDB);
const pouchdb = new PouchDB(
'Campaigns',

View File

@ -2,6 +2,7 @@ import { test, expect } from 'vitest';
import { get } from 'svelte/store';
import { genApi } from './api.js';
import adapter from 'pouchdb-adapter-memory';
const waitUntil = (store, condition) => {
return new Promise((resolve) => {
@ -10,7 +11,10 @@ const waitUntil = (store, condition) => {
};
test('create and add and remove campaigns', async () => {
const api = genApi({ local: true });
const api = genApi({
local: true,
pouch: (p) => p.plugin(adapter),
});
let result = waitUntil(api.campaigns, (r) => r.length === 2);