Skip to content

Commit

Permalink
V1.0.0 (#2)
Browse files Browse the repository at this point in the history
* Initial commit.

* Beta 1.

* Updated README.md

* Added process limit in cli.

* 1.0.0
  • Loading branch information
GiedriusGrabauskas authored Sep 5, 2017
1 parent 170a3b9 commit 1e44a85
Show file tree
Hide file tree
Showing 23 changed files with 636 additions and 733 deletions.
8 changes: 8 additions & 0 deletions @types/arguments.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { OptionsDto } from "./options";
export interface Arguments {
pattern: string;
options: OptionsDto;
uglifyProcessLimit: number;
}
declare const _default: Arguments;
export default _default;
File renamed without changes.
29 changes: 29 additions & 0 deletions @types/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { OptionsDto } from "./options";
export declare class GlobsUglifyJs {
constructor(globPattern: string, options?: OptionsDto);
private globOptions;
private globPattern;
private options;
private filesList;
private filesDetails;
private uglified;
GetFilesList(): Promise<string[]>;
Uglify(processLimit?: number): Promise<void>;
private handlerInfo;
private handleStarter(processLimit);
private tryToStartHandle();
private onFileHandled();
private startHandlingFile(index);
private handleError(error);
private removeSources(successFiles);
private uglifyItem(file);
private buildOutFilePath(filePath);
private uglifyFile(file, options?);
/**
* Asynchronously return files list by pattern.
*
* @param {string} pattern
* @param {glob.IOptions} [options={}]
*/
private getGlobFilesList(pattern, options?);
}
11 changes: 7 additions & 4 deletions dist/options.d.ts → @types/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="uglify-js" />
import * as uglifyjs from "uglify-js";
export interface Options {
export interface OptionsDto {
[key: string]: any;
UseMinExt?: boolean;
MinifyOptions?: uglifyjs.MinifyOptions;
Expand All @@ -9,11 +9,13 @@ export interface Options {
RootDir?: string;
RemoveSource?: boolean;
Debug?: boolean;
exclude?: Array<string> | string;
Exclude?: Array<string> | string;
Silence?: boolean;
}
export default class OptionsConstructor implements Options {
constructor(importData?: Options);
export declare class Options implements OptionsDto {
constructor(importData?: OptionsDto);
private options;
ToObject(): OptionsDto;
readonly UseMinExt: boolean;
readonly MinifyOptions: uglifyjs.MinifyOptions;
readonly OutDir: string;
Expand All @@ -22,4 +24,5 @@ export default class OptionsConstructor implements Options {
readonly RemoveSource: boolean;
readonly Debug: boolean;
readonly Exclude: Array<string> | string | undefined;
readonly Silence: boolean;
}
6 changes: 3 additions & 3 deletions dist/rejection-error.d.ts → @types/rejection-error.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// <reference types="node" />
export default class RejectionError {
export declare class RejectionError {
private error;
private type;
private uniqId;
constructor(error: NodeJS.ErrnoException | Error, type?: string, uniqId?: string);
constructor(error: NodeJS.ErrnoException | Error, type?: string | undefined, uniqId?: string | undefined);
readonly Type: string | undefined;
readonly Error: Error | NodeJS.ErrnoException;
readonly Error: NodeJS.ErrnoException | Error;
readonly UniqId: string | undefined;
private showErrorDetails();
LogError(debug?: boolean): void;
Expand Down
3 changes: 3 additions & 0 deletions @types/utils/directories.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare function Exists(path: string): Promise<boolean>;
export declare function RemoveEmptyDirectories(directoryPath: string): Promise<void>;
export declare function MakeTree(filePath: string): Promise<string>;
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ $ glob-uglifyjs -h
| RootDir | `string` | ` ` | Specifies the root directory of input files. |
| RemoveSource | `boolean` | `false` | Remove all source files specified by glob pattern. |
| Debug | `boolean` | `false` | Show errors details information. |
| 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`. |
| Silence | `boolean` | `false` | Silence all messages in console. |
| 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`. |
| Cwd | `string` | `process.cwd()` | Current working directory. |


Expand Down
7 changes: 0 additions & 7 deletions dist/arguments.d.ts

This file was deleted.

7 changes: 7 additions & 0 deletions dist/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ exports.default = yargs
type: "string"
})
.require("pattern", "Pattern required")
.option("uglifyProcessLimit", {
describe: "Uglify process limit",
type: "number"
})
.default({
"uglifyProcessLimit": 3
})
.config("config")
.alias("c", "config")
.default("config", "glob-uglifyjs.config.json")
Expand Down
19 changes: 18 additions & 1 deletion dist/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/usr/bin/env node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const arguments_1 = require("./arguments");
const main_1 = require("./main");
new main_1.GlobsUglifyJs(arguments_1.default.pattern, arguments_1.default.options || {});
function CliStarter() {
return __awaiter(this, void 0, void 0, function* () {
if (arguments_1.default.uglifyProcessLimit <= 0) {
throw new Error("Uglify process limit must be at least 1.");
}
const globUglifier = new main_1.GlobsUglifyJs(arguments_1.default.pattern, arguments_1.default.options || {});
yield globUglifier.Uglify(arguments_1.default.uglifyProcessLimit);
});
}
CliStarter();
70 changes: 0 additions & 70 deletions dist/main.d.ts

This file was deleted.

Loading

0 comments on commit 1e44a85

Please sign in to comment.