Skip to content

Commit 0abe112

Browse files
authored
Feat: Extract the MinifyResult type (#2)
* Feat: Extract the MinifyResult type * Add publish script
1 parent 1a40224 commit 0abe112

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/email-minifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Sequence } from './sequence';
22
import { createDocument } from './document';
33
import { TaskManager } from './task-manager';
4-
import { Context, ComposeOption } from './types';
4+
import { Context, ComposeOption, MinifyResult } from './types';
55

66
const DEFAULT_COMPOSE_OPTIONS: ComposeOption = {
77
minifyIds: true,
@@ -77,7 +77,7 @@ export class EmailMinifier {
7777
};
7878
}
7979

80-
async minify(options?: ComposeOption) {
80+
async minify(options?: ComposeOption): Promise<MinifyResult> {
8181
const context = await this.createContext();
8282
const taskManager = this.compose(context, options);
8383
const { originalEmailBody, document } = context;

lib/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ export type TaskType =
5757
| 'minify-dataset-attrs'
5858
| 'remove-unused-attrs'
5959
| 'minify-styles';
60+
61+
export type MinifyResult = {
62+
original: string;
63+
minified: string | null;
64+
tasks: Task[];
65+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email-minifier",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"keywords": [
55
"compress",
66
"compressor",
@@ -36,7 +36,8 @@
3636
"scripts": {
3737
"lint": "npx eslint . --fix",
3838
"build": "npm run lint && rm -rf dist && rollup --config --bundleConfigAsCjs",
39-
"test": "npm run lint && jest"
39+
"test": "npm run lint && jest",
40+
"publish": "npm run build && npm publish"
4041
},
4142
"repository": {
4243
"type": "git",

0 commit comments

Comments
 (0)