@cmmn/tools 1.9.13 → 2.0.1

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.
@@ -42,7 +42,7 @@ class Visitor {
42
42
  }
43
43
  }
44
44
  findFile(importPath, sourceFile) {
45
- const sourceFileDir = path.dirname(sourceFile.path);
45
+ const sourceFileDir = path.dirname(sourceFile.fileName);
46
46
 
47
47
  return [
48
48
  importPath,
@@ -56,7 +56,7 @@ class Visitor {
56
56
  ].find(x => fs.existsSync(path.resolve(sourceFileDir, x)))?.replace(/(\.ts)x?$/, '.js');
57
57
  }
58
58
  resolveFile(importPath, sourceFile){
59
- const sourceFileDir = path.dirname(sourceFile.path);
59
+ const sourceFileDir = path.dirname(sourceFile.fileName);
60
60
  const existed = this.findFile(importPath, sourceFile);
61
61
  if (existed) return existed;
62
62
  const suggestions = this.resolver.getImportSuggestions(importPath, sourceFileDir) ?? [];
@@ -72,9 +72,7 @@ class Visitor {
72
72
  */
73
73
  resolve(importPath, sourceFile){
74
74
  importPath = this.resolveFile(importPath, sourceFile);
75
- const sourceFileDir = path.dirname(sourceFile.path);
76
- const caseSensitiveFileNames = this.context.getEmitHost().useCaseSensitiveFileNames();
77
- const formatPath = caseSensitiveFileNames ? x => x : x => x.toLowerCase();
75
+ const sourceFileDir = path.dirname(sourceFile.fileName);
78
76
  const absSource = path.join(this.options.outDir, path.relative(this.options.baseUrl, sourceFileDir));
79
77
  const abs = path.resolve(sourceFileDir, importPath);
80
78
  if (this.config.import.test(importPath)) {
@@ -85,9 +83,6 @@ class Visitor {
85
83
  return importPath+".js";
86
84
  }
87
85
  if (this.config.copy.test(importPath)) {
88
- // console.log(abs, absSource, path.relative(absSource,abs));
89
- // const outFile = path.resolve(absSource, importPath).replaceAll(path.sep, '/');
90
- // fs.cpSync(path.resolve(sourceFileDir, importPath), outFile);
91
86
  return path.relative(absSource,abs);
92
87
  }
93
88
  return importPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.9.13",
3
+ "version": "2.0.1",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -53,7 +53,6 @@
53
53
  "fast-glob": "^3.2.11",
54
54
  "file-uri-to-path": "2.x.x",
55
55
  "import-meta-resolve": "2",
56
- "jasmine-expect": "5.0.0",
57
56
  "less": "^4",
58
57
  "live-server": "1.2.2",
59
58
  "sinon": "17.0.1"
package/test/index.js CHANGED
@@ -1,11 +1,16 @@
1
1
  import * as test from "node:test";
2
2
  Object.assign(globalThis, test);
3
3
  export {suite, test, timeout,} from "@testdeck/jest";
4
- import { expect as expectBase, registerValidator, isEqual} from "earl";
5
- import assert from "node:assert";
4
+ import { expect as expectBase, registerValidator, isEqual, formatCompact} from "earl";
6
5
  // import * as globals from "@jest/globals";
7
6
  export * as sinon from "sinon";
8
- registerValidator("toBe", isEqual)
9
- registerValidator("toBeInstanceOf", type => value => value instanceof type)
10
- registerValidator("toHaveProperty", (prop, value) => obj => isEqual(obj[prop], value))
7
+ registerValidator("toHaveProperty", (control, prop, value) => {
8
+ const actualInline = formatCompact(control.actual)
9
+ const actualValue = formatCompact(control.actual[prop])
10
+ control.assert({
11
+ success: control.actual[prop] === value,
12
+ reason: `The value ${actualInline}[${prop}] = ${actualValue} is not equal to ${value}, but is expected to be eqaul`,
13
+ negatedReason: `The value ${actualInline}[${prop}] = ${actualValue} is equal to ${value}, but is expected not to be eqaul`,
14
+ })
15
+ })
11
16
  export const expect = expectBase;