@cspell/cspell-tools 7.3.0 → 7.3.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.
package/dist/app.js CHANGED
@@ -5,7 +5,7 @@ import { build } from './build.js';
5
5
  import { processCompileAction } from './compile.js';
6
6
  import * as compiler from './compiler/index.js';
7
7
  import { logWithTimestamp } from './compiler/logWithTimestamp.js';
8
- import { gzip } from './gzip/index.js';
8
+ import { gzip, OSFlags } from './gzip/index.js';
9
9
  import { reportCheckChecksumFile, reportChecksumForFiles, updateChecksumForFiles } from './shasum/shasum.js';
10
10
  import { toError } from './util/errors.js';
11
11
  const npmPackageRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
@@ -34,7 +34,7 @@ function addCompileOptions(compileCommand) {
34
34
  export async function run(program, argv, flags) {
35
35
  async function handleGzip(files) {
36
36
  try {
37
- await gzip(files);
37
+ await gzip(files, OSFlags.Unix);
38
38
  }
39
39
  catch (error) {
40
40
  const err = toError(error);
@@ -1,2 +1,14 @@
1
- export declare function compressFile(file: string): Promise<string>;
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ export declare enum OSFlags {
3
+ FAT = 0,
4
+ Unix = 3,
5
+ HPFS = 6,
6
+ MACOS = 7,
7
+ NTFS = 11
8
+ }
9
+ export declare function compressFile(file: string, os?: OSFlags): Promise<string>;
10
+ export declare function compress(buf: string | Uint8Array | Buffer, os?: OSFlags): Promise<Uint8Array>;
11
+ export declare function decompress(buf: Uint8Array | Buffer, encoding?: undefined): Promise<Uint8Array>;
12
+ export declare function decompress(buf: Uint8Array | Buffer, encoding: 'utf8'): Promise<string>;
13
+ export declare function decompress(buf: Uint8Array | Buffer, encoding: 'utf8' | undefined): Promise<string | Uint8Array>;
2
14
  //# sourceMappingURL=compressFiles.d.ts.map
@@ -1,14 +1,36 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { promisify } from 'node:util';
3
- import { gzip as gz } from 'node:zlib';
3
+ import { gunzip as gunzipCB, gzip as gz } from 'node:zlib';
4
4
  const gzip = promisify(gz);
5
- export async function compressFile(file) {
5
+ const gunzip = promisify(gunzipCB);
6
+ export var OSFlags;
7
+ (function (OSFlags) {
8
+ OSFlags[OSFlags["FAT"] = 0] = "FAT";
9
+ OSFlags[OSFlags["Unix"] = 3] = "Unix";
10
+ OSFlags[OSFlags["HPFS"] = 6] = "HPFS";
11
+ OSFlags[OSFlags["MACOS"] = 7] = "MACOS";
12
+ OSFlags[OSFlags["NTFS"] = 11] = "NTFS";
13
+ })(OSFlags || (OSFlags = {}));
14
+ // https://docs.fileformat.com/compression/gz/#:~:text=A%20GZ%20file%20is%20a,compression%20formats%20on%20UNIX%20systems.
15
+ const OSSystemIDOffset = 9;
16
+ export async function compressFile(file, os) {
6
17
  if (file.endsWith('.gz'))
7
18
  return file;
8
19
  const targetFile = file + '.gz';
9
- const buf = await readFile(file);
10
- const zBuf = await gzip(buf);
20
+ const zBuf = await compress(await readFile(file), os);
11
21
  await writeFile(targetFile, zBuf);
12
22
  return targetFile;
13
23
  }
24
+ export async function compress(buf, os) {
25
+ const zBuf = await gzip(buf);
26
+ const osFlag = os ?? zBuf[OSSystemIDOffset];
27
+ zBuf[OSSystemIDOffset] = osFlag;
28
+ return zBuf;
29
+ }
30
+ export async function decompress(buf, encoding) {
31
+ const dBuf = gunzip(buf);
32
+ if (!encoding)
33
+ return dBuf;
34
+ return (await dBuf).toString(encoding);
35
+ }
14
36
  //# sourceMappingURL=compressFiles.js.map
@@ -1,2 +1,3 @@
1
- export declare function gzip(globs: string[]): Promise<void>;
1
+ import type { OSFlags } from './compressFiles.js';
2
+ export declare function gzip(globs: string[], os?: OSFlags): Promise<void>;
2
3
  //# sourceMappingURL=gzip.d.ts.map
package/dist/gzip/gzip.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { globP } from '../util/globP.js';
2
2
  import { compressFile } from './compressFiles.js';
3
3
  // cspell:ignore nodir
4
- export async function gzip(globs) {
4
+ export async function gzip(globs, os) {
5
5
  const files = await globP(globs, { nodir: true });
6
6
  for (const fileName of files) {
7
- await compressFile(fileName);
7
+ await compressFile(fileName, os);
8
8
  }
9
9
  }
10
10
  //# sourceMappingURL=gzip.js.map
@@ -1,3 +1,3 @@
1
- export { compressFile } from './compressFiles.js';
1
+ export { compressFile, OSFlags } from './compressFiles.js';
2
2
  export { gzip } from './gzip.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- export { compressFile } from './compressFiles.js';
1
+ export { compressFile, OSFlags } from './compressFiles.js';
2
2
  export { gzip } from './gzip.js';
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cspell/cspell-tools",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
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.0",
51
+ "@cspell/cspell-pipe": "7.3.1",
52
52
  "commander": "^11.0.0",
53
53
  "cosmiconfig": "8.0.0",
54
- "cspell-trie-lib": "7.3.0",
54
+ "cspell-trie-lib": "7.3.1",
55
55
  "gensequence": "^5.0.2",
56
56
  "glob": "^10.3.4",
57
- "hunspell-reader": "7.3.0",
57
+ "hunspell-reader": "7.3.1",
58
58
  "yaml": "^2.3.2"
59
59
  },
60
60
  "engines": {
@@ -68,5 +68,5 @@
68
68
  "ts-json-schema-generator": "^1.3.0"
69
69
  },
70
70
  "module": "bin.mjs",
71
- "gitHead": "4a16b099b64c5b55645529a4ae79bc32aaf0fc8e"
71
+ "gitHead": "999b382d928e8288ebb8be5b056d04116213f4ee"
72
72
  }