Skip to content

Commit

Permalink
Check for missing arguments before creating output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkmg committed Feb 2, 2018
1 parent b7a8271 commit 314c38b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.0.1 - 2018-02-02
------------------

1. Check for missing arugments before creating output directory.

3.0.0 - 2018-01-22
------------------

Expand All @@ -15,6 +20,11 @@

------------------------------------------------------------------------

2.2.1 - 2018-02-02
------------------

1. Removed console.debug and replaced with process.stderr.write

2.2.0 - 10-01-2018
------------------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easyimage",
"version": "3.0.0",
"version": "3.0.1",
"description": "A promise-based, user-friendly module for processing images in Node.js",
"license": "MIT",
"main": "lib/easyimage.js",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/crop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export async function crop(options: ICropOptions): Promise<IInfoResult> {
upgradeCropOptions(options);
applyDefaultsToCropOptions(options);

await ensureDestinationDirectoryExists(options);

checkForMissingOptions(options, ["src", "cropWidth"]);

await ensureDestinationDirectoryExists(options);

const args: string[] = [options.src];

applyBaseOptionsToArgs(options, args);
Expand Down
4 changes: 3 additions & 1 deletion src/commands/rescrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import * as Bluebird from "bluebird";
import {execute} from "../execute";
import {applyBaseOptionsToArgs, applyDefaultsToBaseOptions, ensureDestinationDirectoryExists} from "../utilities";
import {applyBaseOptionsToArgs, applyDefaultsToBaseOptions, ensureDestinationDirectoryExists, checkForMissingOptions} from "../utilities";
import {ICropOptions} from "./crop";
import {IInfoResult, info} from "./info";
import {IResizeOptions} from "./resize";
Expand All @@ -31,6 +31,8 @@ export async function rescrop(options: IResCropOptions): Promise<IInfoResult> {
upgradeCropOptions(options);
applyDefaultsToRescropOptions(options);

checkForMissingOptions(options, ["src", "cropWidth", "width"]);

await ensureDestinationDirectoryExists(options);

const args: string[] = [options.src];
Expand Down
4 changes: 2 additions & 2 deletions src/commands/resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Promise = Promise || Bluebird as any;
* @returns {Bluebird<IInfoResult>}
*/
export async function resize(options: IResizeOptions): Promise<IInfoResult> {
checkForMissingOptions(options, ["src", "width"]);

applyDefaultsToBaseOptions(options);
applyDefaultsToResizeOptions(options);

checkForMissingOptions(options, ["src", "width"]);

await ensureDestinationDirectoryExists(options);

const args: string[] = [options.src];
Expand Down
3 changes: 2 additions & 1 deletion src/commands/rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ Promise = Promise || Bluebird as any;
* @returns {Bluebird<IInfoResult>}
*/
export async function rotate(options: IRotateOptions): Promise<IInfoResult> {
checkForMissingOptions(options, ["src", "degree"]);
applyDefaultsToBaseOptions(options);

checkForMissingOptions(options, ["src", "degree"]);

await ensureDestinationDirectoryExists(options);

const args: string[] = [options.src];
Expand Down
1 change: 1 addition & 0 deletions src/commands/thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Promise = Promise || Bluebird as any;
export async function thumbnail(options: IThumbnailOptions): Promise<IInfoResult> {
applyDefaultsToBaseOptions(options);
await applyDefaultsToThumbnailOptions(options);

checkForMissingOptions(options, ["src", "width", "height"]);

await ensureDestinationDirectoryExists(options);
Expand Down

0 comments on commit 314c38b

Please sign in to comment.