cspell 5.19.6 → 5.19.7

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/dist/lint/lint.js CHANGED
@@ -43,6 +43,7 @@ const chalk = require("chalk");
43
43
  // eslint-disable-next-line @typescript-eslint/no-var-requires
44
44
  const npmPackage = require('../../package.json');
45
45
  const version = npmPackage.version;
46
+ const { opFilterAsync } = cspell_pipe_1.operators;
46
47
  async function runLint(cfg) {
47
48
  let { reporter } = cfg;
48
49
  cspell.setLogger(getLoggerFromReporter(reporter));
@@ -416,8 +417,8 @@ async function useFileLists(fileListFiles, includeGlobPatterns, root, dot) {
416
417
  options.dot = dot;
417
418
  }
418
419
  const globMatcher = new cspell_glob_1.GlobMatcher(includeGlobPatterns, options);
419
- const files = await (0, fileHelper_1.readFileListFiles)(fileListFiles);
420
420
  const filterFiles = (file) => globMatcher.match(file);
421
- return files instanceof Array ? files.filter(filterFiles) : (0, cspell_pipe_1.pipeAsync)(files, (0, cspell_pipe_1.opFilter)(filterFiles));
421
+ const files = (0, fileHelper_1.readFileListFiles)(fileListFiles);
422
+ return (0, cspell_pipe_1.pipeAsync)(files, (0, cspell_pipe_1.opFilter)(filterFiles), opFilterAsync(fileHelper_1.isNotDir));
422
423
  }
423
424
  //# sourceMappingURL=lint.js.map
@@ -1,2 +1,3 @@
1
- export { toAsyncIterable as mergeAsyncIterables, toArray as asyncIterableToArray, opMap as asyncMap, } from '@cspell/cspell-pipe';
1
+ export { helpers as asyncHelpers, operators as asyncOperators, pipeAsync as asyncPipe, toArray as asyncIterableToArray, toAsyncIterable as mergeAsyncIterables, } from '@cspell/cspell-pipe';
2
+ export declare const asyncMap: typeof import("@cspell/cspell-pipe/operators").opMapAsync, asyncFilter: typeof import("@cspell/cspell-pipe/operators").opFilterAsync, asyncAwait: typeof import("@cspell/cspell-pipe").opAwaitAsync, asyncFlatten: typeof import("@cspell/cspell-pipe/operators").opFlattenAsync;
2
3
  //# sourceMappingURL=async.d.ts.map
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asyncMap = exports.asyncIterableToArray = exports.mergeAsyncIterables = void 0;
4
- var cspell_pipe_1 = require("@cspell/cspell-pipe");
5
- Object.defineProperty(exports, "mergeAsyncIterables", { enumerable: true, get: function () { return cspell_pipe_1.toAsyncIterable; } });
6
- Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_1.toArray; } });
7
- Object.defineProperty(exports, "asyncMap", { enumerable: true, get: function () { return cspell_pipe_1.opMap; } });
3
+ exports.asyncFlatten = exports.asyncAwait = exports.asyncFilter = exports.asyncMap = exports.mergeAsyncIterables = exports.asyncIterableToArray = exports.asyncPipe = exports.asyncOperators = exports.asyncHelpers = void 0;
4
+ const cspell_pipe_1 = require("@cspell/cspell-pipe");
5
+ var cspell_pipe_2 = require("@cspell/cspell-pipe");
6
+ Object.defineProperty(exports, "asyncHelpers", { enumerable: true, get: function () { return cspell_pipe_2.helpers; } });
7
+ Object.defineProperty(exports, "asyncOperators", { enumerable: true, get: function () { return cspell_pipe_2.operators; } });
8
+ Object.defineProperty(exports, "asyncPipe", { enumerable: true, get: function () { return cspell_pipe_2.pipeAsync; } });
9
+ Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_2.toArray; } });
10
+ Object.defineProperty(exports, "mergeAsyncIterables", { enumerable: true, get: function () { return cspell_pipe_2.toAsyncIterable; } });
11
+ exports.asyncMap = cspell_pipe_1.operators.opMapAsync, exports.asyncFilter = cspell_pipe_1.operators.opFilterAsync, exports.asyncAwait = cspell_pipe_1.operators.opAwaitAsync, exports.asyncFlatten = cspell_pipe_1.operators.opFlattenAsync;
8
12
  //# sourceMappingURL=async.js.map
@@ -1,5 +1,6 @@
1
- import { GlobOptions } from './glob';
1
+ /// <reference types="node" />
2
2
  import { CSpellUserSettings, Document, Issue } from 'cspell-lib';
3
+ import { GlobOptions } from './glob';
3
4
  export interface ConfigInfo {
4
5
  source: string;
5
6
  config: CSpellUserSettings;
@@ -29,8 +30,8 @@ export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: strin
29
30
  interface ReadFileInfoResult extends FileInfo {
30
31
  text: string;
31
32
  }
32
- export declare function readFileInfo(filename: string, encoding?: string, handleNotFound?: boolean): Promise<ReadFileInfoResult>;
33
- export declare function readFile(filename: string, encoding?: string): Promise<string>;
33
+ export declare function readFileInfo(filename: string, encoding?: BufferEncoding, handleNotFound?: boolean): Promise<ReadFileInfoResult>;
34
+ export declare function readFile(filename: string, encoding?: BufferEncoding): Promise<string>;
34
35
  /**
35
36
  * Looks for matching glob patterns or stdin
36
37
  * @param globPatterns patterns or stdin
@@ -43,7 +44,7 @@ export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFrom
43
44
  * file will be resolved relative to the containing file.
44
45
  * @returns - a list of files to be processed.
45
46
  */
46
- export declare function readFileListFiles(listFiles: string[]): Promise<string[] | AsyncIterable<string>>;
47
+ export declare function readFileListFiles(listFiles: string[]): AsyncIterable<string>;
47
48
  /**
48
49
  * Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
49
50
  * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
@@ -51,5 +52,8 @@ export declare function readFileListFiles(listFiles: string[]): Promise<string[]
51
52
  * @returns - a list of files to be processed.
52
53
  */
53
54
  export declare function readFileListFile(listFile: string): Promise<string[]>;
55
+ export declare function isFile(filename: string): Promise<boolean>;
56
+ export declare function isDir(filename: string): Promise<boolean>;
57
+ export declare function isNotDir(filename: string): Promise<boolean>;
54
58
  export {};
55
59
  //# sourceMappingURL=fileHelper.d.ts.map
@@ -26,15 +26,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.readFileListFile = exports.readFileListFiles = exports.calcFinalConfigInfo = exports.findFiles = exports.readFile = exports.readFileInfo = exports.fileInfoToDocument = exports.readConfig = void 0;
29
+ exports.isNotDir = exports.isDir = exports.isFile = exports.readFileListFile = exports.readFileListFiles = exports.calcFinalConfigInfo = exports.findFiles = exports.readFile = exports.readFileInfo = exports.fileInfoToDocument = exports.readConfig = void 0;
30
30
  const cspell = __importStar(require("cspell-lib"));
31
- const fsp = __importStar(require("fs-extra"));
31
+ const cspell_lib_1 = require("cspell-lib");
32
+ const fs_1 = require("fs");
32
33
  const get_stdin_1 = __importDefault(require("get-stdin"));
33
- const glob_1 = require("./glob");
34
34
  const path = __importStar(require("path"));
35
- const cspell_lib_1 = require("cspell-lib");
36
- const errors_1 = require("./errors");
37
35
  const async_1 = require("./async");
36
+ const errors_1 = require("./errors");
37
+ const glob_1 = require("./glob");
38
38
  const stdin_1 = require("./stdin");
39
39
  const UTF8 = 'utf8';
40
40
  const STDIN = 'stdin';
@@ -64,7 +64,7 @@ function fileInfoToDocument(fileInfo, languageId, locale) {
64
64
  }
65
65
  exports.fileInfoToDocument = fileInfoToDocument;
66
66
  function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
67
- const pText = filename === STDIN ? (0, get_stdin_1.default)() : fsp.readFile(filename, encoding);
67
+ const pText = filename === STDIN ? (0, get_stdin_1.default)() : fs_1.promises.readFile(filename, encoding);
68
68
  return pText.then((text) => ({ text, filename }), (e) => {
69
69
  const error = (0, errors_1.toError)(e);
70
70
  return handleNotFound && error.code === 'EISDIR'
@@ -117,16 +117,17 @@ const resolveFilenames = (0, async_1.asyncMap)(resolveFilename);
117
117
  * file will be resolved relative to the containing file.
118
118
  * @returns - a list of files to be processed.
119
119
  */
120
- async function readFileListFiles(listFiles) {
120
+ function readFileListFiles(listFiles) {
121
121
  let useStdin = false;
122
122
  const files = listFiles.filter((file) => {
123
123
  const isStdin = file === 'stdin';
124
124
  useStdin = useStdin || isStdin;
125
125
  return !isStdin;
126
126
  });
127
- const found = flatten(await Promise.all(files.map(readFileListFile)));
127
+ const found = (0, async_1.asyncPipe)(files, (0, async_1.asyncMap)((file) => readFileListFile(file)), (0, async_1.asyncAwait)(), (0, async_1.asyncFlatten)());
128
128
  // Move `stdin` to the end.
129
- return useStdin ? resolveFilenames((0, async_1.mergeAsyncIterables)(found, (0, stdin_1.readStdin)())) : found;
129
+ const stdin = useStdin ? (0, stdin_1.readStdin)() : [];
130
+ return (0, async_1.asyncPipe)((0, async_1.mergeAsyncIterables)(found, stdin), resolveFilenames);
130
131
  }
131
132
  exports.readFileListFiles = readFileListFiles;
132
133
  /**
@@ -151,12 +152,28 @@ async function readFileListFile(listFile) {
151
152
  }
152
153
  }
153
154
  exports.readFileListFile = readFileListFile;
154
- function flatten(fileLists) {
155
- function* f() {
156
- for (const list of fileLists) {
157
- yield* list;
158
- }
155
+ async function isFile(filename) {
156
+ try {
157
+ const stat = await fs_1.promises.stat(filename);
158
+ return stat.isFile();
159
159
  }
160
- return [...f()];
160
+ catch (e) {
161
+ return false;
162
+ }
163
+ }
164
+ exports.isFile = isFile;
165
+ async function isDir(filename) {
166
+ try {
167
+ const stat = await fs_1.promises.stat(filename);
168
+ return stat.isDirectory();
169
+ }
170
+ catch (e) {
171
+ return false;
172
+ }
173
+ }
174
+ exports.isDir = isDir;
175
+ function isNotDir(filename) {
176
+ return isDir(filename).then((a) => !a);
161
177
  }
178
+ exports.isNotDir = isNotDir;
162
179
  //# sourceMappingURL=fileHelper.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "5.19.6",
3
+ "version": "5.19.7",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "main": "dist/index.js",
@@ -70,12 +70,12 @@
70
70
  },
71
71
  "homepage": "https://streetsidesoftware.github.io/cspell/",
72
72
  "dependencies": {
73
- "@cspell/cspell-pipe": "^5.19.6",
73
+ "@cspell/cspell-pipe": "^5.19.7",
74
74
  "chalk": "^4.1.2",
75
75
  "commander": "^9.1.0",
76
- "cspell-gitignore": "^5.19.6",
77
- "cspell-glob": "^5.19.6",
78
- "cspell-lib": "^5.19.6",
76
+ "cspell-gitignore": "^5.19.7",
77
+ "cspell-glob": "^5.19.7",
78
+ "cspell-lib": "^5.19.7",
79
79
  "fast-json-stable-stringify": "^2.1.0",
80
80
  "file-entry-cache": "^6.0.1",
81
81
  "fs-extra": "^10.0.1",
@@ -90,8 +90,8 @@
90
90
  "node": ">=12.13.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@cspell/cspell-json-reporter": "^5.19.6",
94
- "@cspell/cspell-types": "^5.19.6",
93
+ "@cspell/cspell-json-reporter": "^5.19.7",
94
+ "@cspell/cspell-types": "^5.19.7",
95
95
  "@types/file-entry-cache": "^5.0.2",
96
96
  "@types/fs-extra": "^9.0.13",
97
97
  "@types/glob": "^7.2.0",
@@ -104,7 +104,7 @@
104
104
  "minimatch": "^5.0.1",
105
105
  "rimraf": "^3.0.2",
106
106
  "rollup": "^2.70.1",
107
- "rollup-plugin-dts": "^4.2.0"
107
+ "rollup-plugin-dts": "^4.2.1"
108
108
  },
109
- "gitHead": "288584aa11eb262dab45201824c90206d7db65c3"
109
+ "gitHead": "1d33cd1b61250f8c4c5c2c218ec43675614784ca"
110
110
  }