harmonyc 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harmonyc",
3
3
  "description": "Harmony Code - model-driven BDD for Vitest",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "author": "Bernát Kalló",
6
6
  "type": "module",
7
7
  "bin": {
package/parser/parser.js CHANGED
@@ -36,15 +36,19 @@ DENTS = apply(alt_sc(tok(T.Plus), tok(T.Minus)), (seqOrFork) => {
36
36
  dent,
37
37
  branch: branch.setFork(isFork),
38
38
  })), ANYTHING_BUT_NEWLINE = anythingBut(T.Newline), TEXT = apply(seq(tok(T.Words), rep_sc(ANYTHING_BUT_NEWLINE)), () => undefined), LINE = alt_sc(NODE, TEXT), TEST_DESIGN = kmid(rep_sc(NEWLINES), apply(opt_sc(list_sc(apply(LINE, (line, [start, end]) => ({ line, start, end })), NEWLINES)), (lines) => {
39
- const startDent = 0;
40
- let dent = startDent;
39
+ let dent;
41
40
  const root = new Section(new Label(''));
42
41
  let parent = root;
43
42
  for (const { line, start } of lines !== null && lines !== void 0 ? lines : []) {
44
43
  if (line === undefined)
45
44
  continue;
46
45
  const { dent: d, branch } = line;
47
- if (Math.round(d) !== d) {
46
+ if (dent === undefined) {
47
+ if (d !== 0)
48
+ throw new Error(`invalid indent ${d} at line ${start.pos.rowBegin}: first step must not be indented`);
49
+ dent = 0;
50
+ }
51
+ else if (Math.round(d) !== d) {
48
52
  throw new Error(`invalid odd indent of ${d * 2} at line ${start.pos.rowBegin}`);
49
53
  }
50
54
  else if (d > dent + 1) {
@@ -54,9 +58,6 @@ DENTS = apply(alt_sc(tok(T.Plus), tok(T.Minus)), (seqOrFork) => {
54
58
  parent = parent.children[parent.children.length - 1];
55
59
  ++dent;
56
60
  }
57
- else if (d < startDent) {
58
- throw new Error(`invalid indent ${d} at line ${start.pos.rowBegin}`);
59
- }
60
61
  else
61
62
  while (d < dent) {
62
63
  parent = parent.parent;
package/vitest/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  import { watchFiles } from "../cli/watch.js";
2
2
  import c from 'tinyrainbow';
3
+ import { compileFiles } from "../compiler/compiler.js";
3
4
  export default function harmonyPlugin({ watchDir, }) {
4
5
  return {
5
6
  name: 'harmony',
6
- configureServer(server) {
7
- watchFiles([`${watchDir}/**/*.harmony`]);
8
- },
9
7
  config(config) {
10
8
  var _a, _b;
11
9
  var _c;
@@ -16,6 +14,16 @@ export default function harmonyPlugin({ watchDir, }) {
16
14
  }
17
15
  config.test.reporters.splice(0, 0, new HarmonyReporter());
18
16
  },
17
+ async configureServer(server) {
18
+ const isWatchMode = server.config.server.watch !== null;
19
+ const patterns = [`${watchDir}/**/*.harmony`];
20
+ if (isWatchMode) {
21
+ await watchFiles(patterns);
22
+ }
23
+ else {
24
+ await compileFiles(patterns);
25
+ }
26
+ },
19
27
  };
20
28
  }
21
29
  class HarmonyReporter {