cspell-tools
Advanced tools
Comparing version 4.1.11 to 4.1.12
@@ -1,3 +0,2 @@ | ||
#!/usr/bin/env node | ||
import * as program from 'commander'; | ||
export declare function run(program: program.Command, argv: string[]): Promise<void>; |
@@ -1,5 +0,3 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
// For large dictionaries, it is necessary to increase the memory limit. | ||
// # !/usr/bin/env node --max_old_space_size=8192 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -9,3 +7,2 @@ const compiler_1 = require("./compiler"); | ||
const path = require("path"); | ||
const program = require("commander"); | ||
const glob = require("glob"); | ||
@@ -73,7 +70,10 @@ const gensequence_1 = require("gensequence"); | ||
exports.run = run; | ||
function parseNumber(s) { | ||
const n = parseInt((s !== null && s !== void 0 ? s : '')); | ||
return isNaN(n) ? undefined : n; | ||
} | ||
async function processAction(src, fileExt, options, action) { | ||
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s \n\n', options.output || 'default', options.compress ? 'true' : 'false', src.join('\n ')); | ||
const ext = fileExt + (options.compress ? '.gz' : ''); | ||
const { max_depth } = options; | ||
const maxDepth = max_depth !== undefined ? Number.parseInt(max_depth) : undefined; | ||
const maxDepth = parseNumber(options.max_depth); | ||
const readerOptions = { maxDepth }; | ||
@@ -109,3 +109,3 @@ const globResults = await Promise.all(src.map(s => globP(s))); | ||
const outFileName = toFilename(filename, ext); | ||
return path.resolve((destination !== null && destination !== void 0 ? destination : './'), outFileName); | ||
return path.resolve((destination !== null && destination !== void 0 ? destination : '.'), outFileName); | ||
} | ||
@@ -138,5 +138,2 @@ async function processFilesIndividually(action, filesToProcess, srcToTarget) { | ||
} | ||
if (require.main === module) { | ||
run(program, process.argv).catch(() => process.exit(1)); | ||
} | ||
//# sourceMappingURL=app.js.map |
import { Sequence } from 'gensequence'; | ||
export interface ReaderOptions { | ||
maxDepth?: number; | ||
} | ||
export declare function readHunspellFiles(filename: string, options: ReaderOptions): Promise<Sequence<string>>; | ||
import { ReaderOptions } from './Reader'; | ||
export declare function streamWordsFromFile(filename: string, options: ReaderOptions): Promise<Sequence<string>>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const gensequence_1 = require("gensequence"); | ||
const HR = require("hunspell-reader"); | ||
const fs = require("fs-extra"); | ||
const cspell_trie_lib_1 = require("cspell-trie-lib"); | ||
const zlib = require("zlib"); | ||
const regHunspellFile = /\.(dic|aff)$/i; | ||
// Readers first match wins | ||
const readers = [ | ||
{ test: /\.trie\b/, method: iterateTrieFile }, | ||
{ test: regHunspellFile, method: readHunspellFiles }, | ||
]; | ||
async function readHunspellFiles(filename, options) { | ||
const dicFile = filename.replace(regHunspellFile, '.dic'); | ||
const affFile = filename.replace(regHunspellFile, '.aff'); | ||
const reader = await HR.IterableHunspellReader.createFromFiles(affFile, dicFile); | ||
reader.maxDepth = options.maxDepth !== undefined ? options.maxDepth : reader.maxDepth; | ||
return gensequence_1.genSequence(reader); | ||
const Reader_1 = require("./Reader"); | ||
async function streamWordsFromFile(filename, options) { | ||
const reader = await Reader_1.createReader(filename, options); | ||
return reader[Symbol.iterator](); | ||
} | ||
exports.readHunspellFiles = readHunspellFiles; | ||
async function iterateTrieFile(filename) { | ||
const trieRoot = cspell_trie_lib_1.importTrie(await iterateFile(filename)); | ||
const trie = new cspell_trie_lib_1.Trie(trieRoot); | ||
return trie.words(); | ||
} | ||
async function iterateFile(filename) { | ||
const content = await fs.readFile(filename) | ||
.then(buffer => (/\.gz$/).test(filename) ? zlib.gunzipSync(buffer) : buffer) | ||
.then(buffer => buffer.toString('UTF-8')); | ||
return gensequence_1.genSequence(content.split('\n')); | ||
} | ||
function streamWordsFromFile(filename, options) { | ||
for (const reader of readers) { | ||
if (reader.test.test(filename)) { | ||
return reader.method(filename, options); | ||
} | ||
} | ||
return iterateFile(filename); | ||
} | ||
exports.streamWordsFromFile = streamWordsFromFile; | ||
//# sourceMappingURL=iterateWordsFromFile.js.map |
{ | ||
"name": "cspell-tools", | ||
"version": "4.1.11", | ||
"version": "4.1.12", | ||
"description": "Tools to assist with the development of cSpell", | ||
@@ -16,3 +16,3 @@ "typings": "dist/index.d.ts", | ||
"coverage": "jest --coverage", | ||
"test-watch": "../../node_modules/.bin/jest --watch", | ||
"test-watch": "jest --watch", | ||
"test": "jest" | ||
@@ -44,9 +44,9 @@ }, | ||
"commander": "^4.0.1", | ||
"cspell-io": "^4.0.19", | ||
"cspell-trie-lib": "^4.1.7", | ||
"cspell-util-bundle": "^4.0.8", | ||
"cspell-io": "^4.0.20", | ||
"cspell-trie-lib": "^4.1.8", | ||
"cspell-util-bundle": "^4.0.9", | ||
"fs-extra": "^8.1.0", | ||
"gensequence": "^3.0.1", | ||
"gensequence": "^3.0.3", | ||
"glob": "^7.1.6", | ||
"hunspell-reader": "^3.1.4", | ||
"hunspell-reader": "^3.2.0", | ||
"iconv-lite": "^0.4.24", | ||
@@ -76,3 +76,3 @@ "minimatch": "^3.0.4" | ||
}, | ||
"gitHead": "73f2223b8b222203c2e996d865564ef85fb67075" | ||
"gitHead": "cbe103ba540d0ec7af38876372722802f80f4098" | ||
} |
23442
19
466
Updatedcspell-io@^4.0.20
Updatedcspell-trie-lib@^4.1.8
Updatedcspell-util-bundle@^4.0.9
Updatedgensequence@^3.0.3
Updatedhunspell-reader@^3.2.0