From 0c048f42454a9db129f7f07626ef35bca4d55bc9 Mon Sep 17 00:00:00 2001
From: Peter Juras
Date: Sat, 23 Jan 2016 23:36:14 +0100
Subject: [PATCH] Add type definitions for gulp-json-editor
---
gulp-json-editor/gulp-json-editor-tests.ts | 40 +++++++++++++++++
gulp-json-editor/gulp-json-editor.d.ts | 17 ++++++++
js-beautify/js-beautify.d.ts | 50 ++++++++++++----------
3 files changed, 85 insertions(+), 22 deletions(-)
create mode 100644 gulp-json-editor/gulp-json-editor-tests.ts
create mode 100644 gulp-json-editor/gulp-json-editor.d.ts
diff --git a/gulp-json-editor/gulp-json-editor-tests.ts b/gulp-json-editor/gulp-json-editor-tests.ts
new file mode 100644
index 0000000000..a6acbb8369
--- /dev/null
+++ b/gulp-json-editor/gulp-json-editor-tests.ts
@@ -0,0 +1,40 @@
+///
+///
+
+import * as gulp from 'gulp';
+import * as jeditor from 'gulp-json-editor';
+
+// Samples taken from https://www.npmjs.com/package/gulp-json-editor
+
+/*
+ edit JSON object by merging with user specific object
+*/
+gulp.src("./manifest.json")
+ .pipe(jeditor({
+ 'version': '1.2.3'
+ }))
+ .pipe(gulp.dest("./dest"));
+
+/*
+ edit JSON object by using user specific function
+*/
+gulp.src("./manifest.json")
+ .pipe(jeditor(function(json : any) {
+ json.version = "1.2.3";
+ return json; // must return JSON object.
+ }))
+ .pipe(gulp.dest("./dest"));
+
+/*
+ specify js-beautify option
+*/
+gulp.src("./manifest.json")
+ .pipe(jeditor({
+ 'version': '1.2.3'
+ },
+ // the second argument is passed to js-beautify as its option
+ {
+ 'indent_char': '\t',
+ 'indent_size': 1
+ }))
+ .pipe(gulp.dest("./dest"));
diff --git a/gulp-json-editor/gulp-json-editor.d.ts b/gulp-json-editor/gulp-json-editor.d.ts
new file mode 100644
index 0000000000..55a49f5b2a
--- /dev/null
+++ b/gulp-json-editor/gulp-json-editor.d.ts
@@ -0,0 +1,17 @@
+// Type definitions for gulp-json-editor v2.2.1
+// Project: https://www.npmjs.com/package/gulp-json-editor
+// Definitions by: Peter Juras
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+///
+///
+
+declare module "gulp-json-editor" {
+
+ interface JEditor {
+ (mergeWith: any | ((json : any) => any ),
+ jsBeautifyOptions? : JsBeautifyOptions ) : NodeJS.ReadWriteStream;
+ }
+
+ const jeditor : JEditor;
+ export = jeditor;
+}
diff --git a/js-beautify/js-beautify.d.ts b/js-beautify/js-beautify.d.ts
index fc581ea90a..41f1a41ff1 100644
--- a/js-beautify/js-beautify.d.ts
+++ b/js-beautify/js-beautify.d.ts
@@ -2,28 +2,34 @@
// Project: https://github.com/beautify-web/js-beautify/
// Definitions by: Josh Goldberg
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+// Type definitions for js_beautify
+// Project: https://github.com/beautify-web/js-beautify/
+// Definitions by: Josh Goldberg
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+interface JsBeautifyOptions {
+ indent_size?: number;
+ indent_char?: string;
+ eol?: string;
+ indent_level?: number;
+ indent_with_tabs?: boolean;
+ preserve_newlines?: boolean;
+ max_preserve_newlines?: number;
+ jslint_happy?: boolean;
+ space_after_anon_function?: boolean;
+ brace_style?: string;
+ keep_array_indentation?: boolean;
+ keep_function_indentation?: boolean;
+ space_before_conditional?: boolean;
+ break_chained_methods?: boolean;
+ eval_code?: boolean;
+ unescape_strings?: boolean;
+ wrap_line_length?: number;
+ wrap_attributes?: string;
+ wrap_attributes_indent_size?: number;
+ end_with_newline?: boolean;
+}
declare var js_beautify: {
- (js_source_text: string, options?: {
- indent_size?: number;
- indent_char?: string;
- eol?: string;
- indent_level?: number;
- indent_with_tabs?: boolean;
- preserve_newlines?: boolean;
- max_preserve_newlines?: number;
- jslint_happy: boolean;
- space_after_anon_function: boolean;
- brace_style: string;
- keep_array_indentation: boolean;
- keep_function_indentation: boolean;
- space_before_conditional: boolean;
- break_chained_methods: boolean;
- eval_code: boolean;
- unescape_strings: boolean;
- wrap_line_length: number;
- wrap_attributes: string;
- wrap_attributes_indent_size: number;
- end_with_newline: boolean;
- }): string;
+ (js_source_text: string, options?: JsBeautifyOptions): string;
};