Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 1e44a85

Browse files
V1.0.0 (#2)
* Initial commit. * Beta 1. * Updated README.md * Added process limit in cli. * 1.0.0
1 parent 170a3b9 commit 1e44a85

23 files changed

Lines changed: 636 additions & 733 deletions

@types/arguments.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { OptionsDto } from "./options";
2+
export interface Arguments {
3+
pattern: string;
4+
options: OptionsDto;
5+
uglifyProcessLimit: number;
6+
}
7+
declare const _default: Arguments;
8+
export default _default;
File renamed without changes.

@types/main.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { OptionsDto } from "./options";
2+
export declare class GlobsUglifyJs {
3+
constructor(globPattern: string, options?: OptionsDto);
4+
private globOptions;
5+
private globPattern;
6+
private options;
7+
private filesList;
8+
private filesDetails;
9+
private uglified;
10+
GetFilesList(): Promise<string[]>;
11+
Uglify(processLimit?: number): Promise<void>;
12+
private handlerInfo;
13+
private handleStarter(processLimit);
14+
private tryToStartHandle();
15+
private onFileHandled();
16+
private startHandlingFile(index);
17+
private handleError(error);
18+
private removeSources(successFiles);
19+
private uglifyItem(file);
20+
private buildOutFilePath(filePath);
21+
private uglifyFile(file, options?);
22+
/**
23+
* Asynchronously return files list by pattern.
24+
*
25+
* @param {string} pattern
26+
* @param {glob.IOptions} [options={}]
27+
*/
28+
private getGlobFilesList(pattern, options?);
29+
}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="uglify-js" />
22
import * as uglifyjs from "uglify-js";
3-
export interface Options {
3+
export interface OptionsDto {
44
[key: string]: any;
55
UseMinExt?: boolean;
66
MinifyOptions?: uglifyjs.MinifyOptions;
@@ -9,11 +9,13 @@ export interface Options {
99
RootDir?: string;
1010
RemoveSource?: boolean;
1111
Debug?: boolean;
12-
exclude?: Array<string> | string;
12+
Exclude?: Array<string> | string;
13+
Silence?: boolean;
1314
}
14-
export default class OptionsConstructor implements Options {
15-
constructor(importData?: Options);
15+
export declare class Options implements OptionsDto {
16+
constructor(importData?: OptionsDto);
1617
private options;
18+
ToObject(): OptionsDto;
1719
readonly UseMinExt: boolean;
1820
readonly MinifyOptions: uglifyjs.MinifyOptions;
1921
readonly OutDir: string;
@@ -22,4 +24,5 @@ export default class OptionsConstructor implements Options {
2224
readonly RemoveSource: boolean;
2325
readonly Debug: boolean;
2426
readonly Exclude: Array<string> | string | undefined;
27+
readonly Silence: boolean;
2528
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/// <reference types="node" />
2-
export default class RejectionError {
2+
export declare class RejectionError {
33
private error;
44
private type;
55
private uniqId;
6-
constructor(error: NodeJS.ErrnoException | Error, type?: string, uniqId?: string);
6+
constructor(error: NodeJS.ErrnoException | Error, type?: string | undefined, uniqId?: string | undefined);
77
readonly Type: string | undefined;
8-
readonly Error: Error | NodeJS.ErrnoException;
8+
readonly Error: NodeJS.ErrnoException | Error;
99
readonly UniqId: string | undefined;
1010
private showErrorDetails();
1111
LogError(debug?: boolean): void;

@types/utils/directories.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare function Exists(path: string): Promise<boolean>;
2+
export declare function RemoveEmptyDirectories(directoryPath: string): Promise<void>;
3+
export declare function MakeTree(filePath: string): Promise<string>;

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ $ glob-uglifyjs -h
6767
| RootDir | `string` | ` ` | Specifies the root directory of input files. |
6868
| RemoveSource | `boolean` | `false` | Remove all source files specified by glob pattern. |
6969
| Debug | `boolean` | `false` | Show errors details information. |
70-
| exclude | `string` \| `string[]` | `undefined` | Add a pattern or an array of glob patterns to exclude matches. Read more in [node-glob options](https://github.com/isaacs/node-glob#options) `ignore`. |
70+
| Silence | `boolean` | `false` | Silence all messages in console. |
71+
| Exclude | `string` \| `string[]` | `undefined` | Add a pattern or an array of glob patterns to exclude matches. Read more in [node-glob options](https://github.com/isaacs/node-glob#options) `ignore`. |
7172
| Cwd | `string` | `process.cwd()` | Current working directory. |
7273

7374

dist/arguments.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

dist/arguments.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ exports.default = yargs
1717
type: "string"
1818
})
1919
.require("pattern", "Pattern required")
20+
.option("uglifyProcessLimit", {
21+
describe: "Uglify process limit",
22+
type: "number"
23+
})
24+
.default({
25+
"uglifyProcessLimit": 3
26+
})
2027
.config("config")
2128
.alias("c", "config")
2229
.default("config", "glob-uglifyjs.config.json")

dist/cli.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
#!/usr/bin/env node
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
210
Object.defineProperty(exports, "__esModule", { value: true });
311
const arguments_1 = require("./arguments");
412
const main_1 = require("./main");
5-
new main_1.GlobsUglifyJs(arguments_1.default.pattern, arguments_1.default.options || {});
13+
function CliStarter() {
14+
return __awaiter(this, void 0, void 0, function* () {
15+
if (arguments_1.default.uglifyProcessLimit <= 0) {
16+
throw new Error("Uglify process limit must be at least 1.");
17+
}
18+
const globUglifier = new main_1.GlobsUglifyJs(arguments_1.default.pattern, arguments_1.default.options || {});
19+
yield globUglifier.Uglify(arguments_1.default.uglifyProcessLimit);
20+
});
21+
}
22+
CliStarter();

0 commit comments

Comments
 (0)