Skip to content

Commit

Permalink
fix: drop need for iconv-lite and iterable-to-stream
Browse files Browse the repository at this point in the history
- iterable-to-stream - was replaced with the now built-in method.
- iconv-lite - was never really needed since all files are expected to be in `utf-8`.
- Bump the minimum version of not to the original LTS version 12.13.0
  • Loading branch information
Jason3S committed Sep 11, 2021
1 parent ae91c44 commit e688e2b
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/cspell-bundled-dicts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@cspell/dict-typescript": "^1.0.19"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@cspell/cspell-tools": "^5.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-dynamic-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"author": "Jason Dent",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"peerDependencies": {
"cspell": "^5.8.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-glob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-glob"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"dependencies": {
"micromatch": "^4.0.4"
Expand Down
28 changes: 7 additions & 21 deletions packages/cspell-io/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions packages/cspell-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-io"
},
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
"dependencies": {
"iconv-lite": "^0.6.3",
"iterable-to-stream": "^2.0.0"
},
"dependencies": {},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.12",
Expand Down
5 changes: 2 additions & 3 deletions packages/cspell-io/src/file/fileReader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// cSpell:ignore curr
// cSpell:words zlib iconv
import * as fs from 'fs';
import * as iconv from 'iconv-lite';
import * as zlib from 'zlib';
import * as readline from 'readline';

Expand Down Expand Up @@ -32,15 +31,15 @@ export function lineReaderAsync(filename: string, encoding: BufferEncoding = def
return streamFileLineByLineAsync(filename, encoding);
}

function prepareFileStream(filename: string, encoding: string, fnError: (e: Error) => void) {
function prepareFileStream(filename: string, encoding: BufferEncoding, fnError: (e: Error) => void) {
const pipes: NodeJS.ReadWriteStream[] = [];
if (filename.match(/\.gz$/i)) {
pipes.push(zlib.createGunzip());
}
pipes.push(iconv.decodeStream(encoding));
const fileStream = fs.createReadStream(filename);
fileStream.on('error', fnError);
const stream = pipes.reduce<NodeJS.ReadableStream>((s, p) => s.pipe(p).on('error', fnError), fileStream);
stream.setEncoding(encoding);
return stream;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/cspell-io/src/file/fileWriter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as fs from 'fs';
import * as zlib from 'zlib';
import * as stream from 'stream';
import { iterableToStream } from 'iterable-to-stream';

export function writeToFile(filename: string, data: string): NodeJS.WritableStream {
return writeToFileIterable(filename, [data]);
}

export function writeToFileIterable(filename: string, data: Iterable<string>): NodeJS.WritableStream {
const sourceStream = iterableToStream(data);
const sourceStream = stream.Readable.from(data);
const writeStream = fs.createWriteStream(filename);
const zip = filename.match(/\.gz$/) ? zlib.createGzip() : new stream.PassThrough();
return sourceStream.pipe(zip).pipe(writeStream);
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"vscode-uri": "^3.0.2"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@cspell/dict-cpp": "^1.1.40",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"hunspell-reader": "^5.9.0"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"gensequence": "^3.1.1"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@cspell/dict-en_us": "^2.1.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/cspell-trie/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/cspell-trie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@
"commander": "^8.2.0",
"cspell-trie-lib": "^5.9.0",
"fs-extra": "^10.0.0",
"gensequence": "^3.1.1",
"iterable-to-stream": "^2.0.0"
"gensequence": "^3.1.1"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.12",
Expand Down
6 changes: 3 additions & 3 deletions packages/cspell-trie/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mkdirp } from 'fs-extra';
import * as path from 'path';
import * as Trie from 'cspell-trie-lib';
import { Sequence, genSequence } from 'gensequence';
import { iterableToStream } from 'iterable-to-stream';
import * as stream from 'stream';
import * as zlib from 'zlib';

const UTF8: BufferEncoding = 'utf8';
Expand Down Expand Up @@ -41,7 +41,7 @@ export function run(program: commander.Command, argv: string[]): Promise<command
const trie = Trie.buildTrie(wordsRx);

notify('Export Trie');
const serialStream = iterableToStream(Trie.serializeTrie(trie.root, base - 0 || 32));
const serialStream = stream.Readable.from(Trie.serializeTrie(trie.root, base - 0 || 32));
const outputStream = await pOutputStream;
return new Promise((resolve) => {
serialStream.pipe(outputStream).on('finish', () => resolve());
Expand All @@ -61,7 +61,7 @@ export function run(program: commander.Command, argv: string[]): Promise<command
const words: Sequence<string> = Trie.iteratorTrieWords(root);
const outputStream = await pOutputStream;
return new Promise((resolve) => {
iterableToStream(words.map((a) => a + '\n'))
stream.Readable.from(words.map((a) => a + '\n'))
.pipe(outputStream)
.on('finish', () => resolve());
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie2-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"jest": "^27.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"author": "Jason Dent",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"ajv-cli": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"vscode-uri": "^3.0.2"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
},
"devDependencies": {
"@cspell/cspell-types": "^5.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/hunspell-reader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"rules": {}
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.13.0"
}
}

0 comments on commit e688e2b

Please sign in to comment.