@divriots/jampack 0.2.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
1
  import sharp from 'sharp';
2
2
  import type { Image } from './types.js';
3
3
  export declare const compressImage: (data: Buffer, resize: sharp.ResizeOptions, toWebp?: boolean) => Promise<Image | undefined>;
4
- export declare function compress(glob: string): Promise<void>;
4
+ export declare function compress(exclude: string): Promise<void>;
package/dist/compress.js CHANGED
@@ -158,9 +158,12 @@ const compressImageFile = async (file, toWebP = false) => {
158
158
  const buffer = await fs.readFile(file);
159
159
  return compressImage(buffer, {}, toWebP);
160
160
  };
161
- export async function compress(glob) {
161
+ export async function compress(exclude) {
162
162
  beginProgress();
163
- const paths = await globby(glob, { cwd: globalState.dir, absolute: true });
163
+ const globs = ['**/**'];
164
+ if (exclude)
165
+ globs.push('!' + exclude);
166
+ const paths = await globby(globs, { cwd: globalState.dir, absolute: true });
164
167
  // "Parallel" processing
165
168
  await Promise.all(paths.map(async (file) => {
166
169
  if (!globalState.compressedFiles.has(file)) {
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ program
23
23
  program.command('pack', { isDefault: true })
24
24
  .description('todo')
25
25
  .argument('<dir>', 'Directory to pack')
26
+ .option('--exclude <exclude>', 'Glob to exclude')
26
27
  .option('--nowrite', 'No write')
27
28
  .option('--onlycomp', 'Only compress')
28
29
  .option('--onlyoptim', 'Only optimize')
@@ -32,12 +33,12 @@ program.command('pack', { isDefault: true })
32
33
  if (!options.onlycomp) {
33
34
  console.log('');
34
35
  console.log(kleur.bgGreen(kleur.black(` PASS 1 - Optimizing `)));
35
- await optimize();
36
+ await optimize(options.exclude);
36
37
  }
37
38
  if (!options.onlyoptim) {
38
39
  console.log('');
39
40
  console.log(kleur.bgGreen(kleur.black(` PASS 2 - Compressing the rest`)));
40
- await compress("**/**");
41
+ await compress(options.exclude);
41
42
  }
42
43
  printDetails();
43
44
  });
@@ -1 +1 @@
1
- export declare function optimize(): Promise<void>;
1
+ export declare function optimize(exclude?: string): Promise<void>;
package/dist/optimize.js CHANGED
@@ -275,8 +275,11 @@ function setImageSize(img, meta) {
275
275
  // Something when wrong
276
276
  throw new Error('Unexpected issue when resolving image sizes');
277
277
  }
278
- export async function optimize() {
279
- const paths = await globby('**/*.{htm,html}', { cwd: globalState.dir });
278
+ export async function optimize(exclude) {
279
+ const glob = ['**/*.{htm,html}'];
280
+ if (exclude)
281
+ glob.push('!' + exclude);
282
+ const paths = await globby(glob, { cwd: globalState.dir });
280
283
  // Sequential async
281
284
  await paths.reduce(async (previousPromise, item) => {
282
285
  await previousPromise;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {