@cspell/cspell-tools 7.3.2 → 7.3.4

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.
@@ -1,4 +1,3 @@
1
1
  import type { Reader, ReaderOptions } from './readers/ReaderOptions.js';
2
- export declare const regHunspellFile: RegExp;
3
2
  export declare function createReader(filename: string, options: ReaderOptions): Promise<Reader>;
4
3
  //# sourceMappingURL=Reader.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { readHunspellFiles } from './readers/readHunspellFiles.js';
2
+ import { regHunspellFile } from './readers/regHunspellFile.js';
2
3
  import { textFileReader } from './readers/textFileReader.js';
3
4
  import { trieFileReader } from './readers/trieFileReader.js';
4
- export const regHunspellFile = /\.(dic|aff)$/i;
5
5
  // Readers first match wins
6
6
  const readers = [
7
7
  { test: /\.trie\b/, method: trieFileReader },
@@ -1,7 +1,7 @@
1
1
  import { pipe } from '@cspell/cspell-pipe/sync';
2
2
  import { COMPOUND_FIX, FORBID_PREFIX } from 'cspell-trie-lib';
3
3
  import * as HR from 'hunspell-reader';
4
- import { regHunspellFile } from '../Reader.js';
4
+ import { regHunspellFile } from './regHunspellFile.js';
5
5
  const DEDUPE_SIZE = 1000;
6
6
  export async function readHunspellFiles(filename, options) {
7
7
  const dicFile = filename.replace(regHunspellFile, '.dic');
@@ -0,0 +1,2 @@
1
+ export declare const regHunspellFile: RegExp;
2
+ //# sourceMappingURL=regHunspellFile.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const regHunspellFile = /\.(dic|aff)$/i;
2
+ //# sourceMappingURL=regHunspellFile.js.map
@@ -106,7 +106,8 @@ export function createParseFileLineMapper(options) {
106
106
  function splitLine(line) {
107
107
  line = line.replace(/#.*/, ''); // remove comment
108
108
  line = line.trim();
109
- line = line.replace(/\bU\+[0-9A-F]+\b/gi, '|'); // Remove Unicode Definitions
109
+ line = line.replace(/\bU\+[0-9A-F]{4}\b/gi, '|'); // Remove Unicode Definitions
110
+ line = line.replace(/\\U[0-9A-F]{4}/gi, '|'); // Remove Unicode Definitions
110
111
  line = line.replace(regNonWordOrDigit, '|');
111
112
  line = line.replace(/'(?=\|)/g, ''); // remove trailing '
112
113
  line = line.replace(/'$/, ''); // remove trailing '
@@ -121,8 +122,7 @@ export function createParseFileLineMapper(options) {
121
122
  .map((a) => a.trim())
122
123
  .filter((a) => !!a)
123
124
  .filter((a) => !a.match(/^[0-9_-]+$/)) // pure numbers and symbols
124
- .filter((a) => !a.match(/^[ux][0-9A-F]*$/i)) // hex digits
125
- .filter((a) => !a.match(/^0[xo][0-9A-F]*$/i)); // c-style hex/octal digits
125
+ .filter((a) => !a.match(/^0[xo][0-9A-F]+$/i)); // c-style hex/octal digits
126
126
  return lines;
127
127
  }
128
128
  function* splitWords(lines) {
@@ -29,12 +29,11 @@ export interface TestHelper {
29
29
  */
30
30
  mkdir(...parts: string[]): void;
31
31
  /**
32
- * copy files
33
- * same as shell.cp
32
+ * copy file
34
33
  * @param from
35
34
  * @param to
36
35
  */
37
- cp(from: string, to: string): void;
36
+ cpFileSync(from: string, to: string): void;
38
37
  packageTemp(...parts: string[]): string;
39
38
  /**
40
39
  * Signal the start of a test.
@@ -1,7 +1,6 @@
1
1
  import assert from 'assert';
2
- import { promises as fs } from 'fs';
2
+ import { mkdirSync, promises as fs, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
3
3
  import * as path from 'path';
4
- import * as shell from 'shelljs';
5
4
  import { fileURLToPath } from 'url';
6
5
  import { expect } from 'vitest';
7
6
  const _dirname = test_dirname(import.meta.url);
@@ -41,7 +40,7 @@ class TestHelperImpl {
41
40
  * delete the contents of the temp directory for the current test.
42
41
  */
43
42
  clearTempDir() {
44
- shell.rm('-rf', this.resolveTemp());
43
+ rmSync(this.resolveTemp(), { force: true, recursive: true });
45
44
  }
46
45
  /**
47
46
  * resolve a path relative to the
@@ -59,15 +58,17 @@ class TestHelperImpl {
59
58
  */
60
59
  mkdir(...parts) {
61
60
  const pTemp = this.resolveTemp(...parts);
62
- shell.mkdir('-p', pTemp);
61
+ mkdirSync(pTemp, { recursive: true });
63
62
  }
64
63
  /**
65
64
  * Copy files from src to dest
66
65
  * @param src - glob
67
66
  * @param dest - directory or file
68
67
  */
69
- cp(src, dest) {
70
- shell.cp(this.resolveTemp(src), this.resolveTemp(dest));
68
+ cpFileSync(src, dest) {
69
+ const srcT = this.resolveTemp(src);
70
+ const dstT = this.resolveTemp(dest);
71
+ cpFileSync(srcT, dstT);
71
72
  }
72
73
  /**
73
74
  * resolve a path to the fixtures.
@@ -102,9 +103,17 @@ export function resolvePathToFixture(...segments) {
102
103
  return path.resolve(fixtureDir, ...segments);
103
104
  }
104
105
  export function test_dirname(importMetaUrl) {
105
- return path.dirname(test_filename(importMetaUrl));
106
+ return fileURLToPath(new URL('.', importMetaUrl));
106
107
  }
107
108
  export function test_filename(importMetaUrl) {
108
109
  return fileURLToPath(importMetaUrl);
109
110
  }
111
+ function cpFileSync(srcFile, dst) {
112
+ const statDst = statSync(dst, { throwIfNoEntry: false });
113
+ if (statDst && statDst.isDirectory()) {
114
+ dst = path.join(dst, path.basename(srcFile));
115
+ }
116
+ const buf = readFileSync(srcFile);
117
+ writeFileSync(dst, buf);
118
+ }
110
119
  //# sourceMappingURL=TestHelper.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cspell/cspell-tools",
3
- "version": "7.3.2",
3
+ "version": "7.3.4",
4
4
  "description": "Tools to assist with the development of cSpell",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -48,13 +48,13 @@
48
48
  },
49
49
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
50
50
  "dependencies": {
51
- "@cspell/cspell-pipe": "7.3.2",
51
+ "@cspell/cspell-pipe": "7.3.4",
52
52
  "commander": "^11.0.0",
53
53
  "cosmiconfig": "8.0.0",
54
- "cspell-trie-lib": "7.3.2",
54
+ "cspell-trie-lib": "7.3.4",
55
55
  "gensequence": "^5.0.2",
56
56
  "glob": "^10.3.4",
57
- "hunspell-reader": "7.3.2",
57
+ "hunspell-reader": "7.3.4",
58
58
  "yaml": "^2.3.2"
59
59
  },
60
60
  "engines": {
@@ -62,11 +62,9 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/glob": "^8.1.0",
65
- "@types/shelljs": "^0.8.12",
66
65
  "lorem-ipsum": "^2.0.8",
67
- "shelljs": "^0.8.5",
68
66
  "ts-json-schema-generator": "^1.3.0"
69
67
  },
70
68
  "module": "bin.mjs",
71
- "gitHead": "71d88d4e4d2252124a952c78d4fc03ce0a6d67e3"
69
+ "gitHead": "7849a4ff2561453653fae9b9067b39252aeb773f"
72
70
  }