@argos-ci/core 4.1.0 → 4.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -587,16 +587,43 @@ var mustBeArgosToken = (value) => {
587
587
  throw new Error("Invalid Argos repository token (must be 40 characters)");
588
588
  }
589
589
  };
590
+ var minInteger = (min) => (value) => {
591
+ if (!Number.isInteger(value)) {
592
+ throw new Error("must be an integer");
593
+ }
594
+ if (value < min) {
595
+ throw new Error(`must be at least ${min}`);
596
+ }
597
+ };
598
+ var toInt = (value) => {
599
+ if (value === "") {
600
+ return null;
601
+ }
602
+ const num = Number(value);
603
+ if (!Number.isInteger(num) || Number.isNaN(num)) {
604
+ return num;
605
+ }
606
+ return num;
607
+ };
608
+ var toFloat = (value) => parseFloat(value);
609
+ convict.addFormat({
610
+ name: "parallel-total",
611
+ validate: minInteger(-1),
612
+ coerce: toInt
613
+ });
614
+ convict.addFormat({
615
+ name: "parallel-index",
616
+ validate: minInteger(1),
617
+ coerce: toInt
618
+ });
590
619
  convict.addFormat({
591
620
  name: "float-percent",
592
- validate: function(val) {
621
+ validate: (val) => {
593
622
  if (val !== 0 && (!val || val > 1 || val < 0)) {
594
623
  throw new Error("Must be a float between 0 and 1, inclusive.");
595
624
  }
596
625
  },
597
- coerce: function(val) {
598
- return parseFloat(val);
599
- }
626
+ coerce: toFloat
600
627
  });
601
628
  var schema = {
602
629
  apiBaseUrl: {
@@ -662,13 +689,13 @@ var schema = {
662
689
  },
663
690
  parallelIndex: {
664
691
  env: "ARGOS_PARALLEL_INDEX",
665
- format: "nat",
692
+ format: "parallel-index",
666
693
  default: null,
667
694
  nullable: true
668
695
  },
669
696
  parallelTotal: {
670
697
  env: "ARGOS_PARALLEL_TOTAL",
671
- format: "int",
698
+ format: "parallel-total",
672
699
  default: null,
673
700
  nullable: true
674
701
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Node.js SDK for visual testing with Argos.",
4
- "version": "4.1.0",
4
+ "version": "4.1.2",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -64,5 +64,5 @@
64
64
  "lint": "eslint .",
65
65
  "test": "vitest"
66
66
  },
67
- "gitHead": "74818a1d3fe21574d0884c828ee709e62605d974"
67
+ "gitHead": "c705285fa19c31ef0c071bc7bf5182f7a366e2c4"
68
68
  }