From 4b40d74d0bf7ea8b9abd1553ca7d6a643e72b9e4 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 6 Mar 2017 15:30:29 +1100 Subject: [PATCH 1/2] sketching out the type declarations for klaw-sync --- klaw-sync/index.d.ts | 37 ++++++++++++++++++++++++++++++++++++ klaw-sync/klaw-sync-tests.ts | 20 +++++++++++++++++++ klaw-sync/tsconfig.json | 22 +++++++++++++++++++++ klaw-sync/tslint.json | 9 +++++++++ 4 files changed, 88 insertions(+) create mode 100644 klaw-sync/index.d.ts create mode 100644 klaw-sync/klaw-sync-tests.ts create mode 100644 klaw-sync/tsconfig.json create mode 100644 klaw-sync/tslint.json diff --git a/klaw-sync/index.d.ts b/klaw-sync/index.d.ts new file mode 100644 index 0000000000..09342094e0 --- /dev/null +++ b/klaw-sync/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for klaw-sync v1.1.2 +// Project: https://github.com/manidlou/node-klaw-sync +// Definitions by: Brendan Forster +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as fs from "fs" + +interface Item { + path: string + stats: fs.Stats +} + +interface Options { + /** + * any paths or `micromatch` patterns to ignore. + * + * For more information on micromatch patterns: https://github.com/jonschlinkert/micromatch#features + */ + ignore?: string | string[] + /** + * True to only return files (ignore directories). + * + * Defaults to false if not specified. + */ + nodir?: boolean + /** + * True to only return directories (ignore files). + * + * Defaults to false if not specified. + */ + nofile?: boolean +} + +export function klawSync(root: string, options?: Options): ReadonlyArray + diff --git a/klaw-sync/klaw-sync-tests.ts b/klaw-sync/klaw-sync-tests.ts new file mode 100644 index 0000000000..5c2b806108 --- /dev/null +++ b/klaw-sync/klaw-sync-tests.ts @@ -0,0 +1,20 @@ +import { klawSync, Item } from "klaw-sync" +import * as path from "path" + +const outputMessage = (result: Item) => { + console.log(`file: ${result.path} has size '${result.stats.size}'`) +} + +klawSync('/some/dir').forEach(outputMessage) + +const defaultOptions = { } + +klawSync('/some/dir', defaultOptions).forEach(outputMessage) + +const options = { + ignore: [ '.exe' ], + nodir: true, + nofile: false +} + +klawSync('/some/dir', options).forEach(outputMessage) diff --git a/klaw-sync/tsconfig.json b/klaw-sync/tsconfig.json new file mode 100644 index 0000000000..ca120a7ba3 --- /dev/null +++ b/klaw-sync/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "klaw-sync-tests.ts" + ] +} diff --git a/klaw-sync/tslint.json b/klaw-sync/tslint.json new file mode 100644 index 0000000000..7cf0e1c353 --- /dev/null +++ b/klaw-sync/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "../tslint.json", + "rules": { + "semicolon": [ + true, + "never" + ] + } +} From a413462a324b22d0bccb073ac9fd5de6b85e6a7e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 6 Mar 2017 15:51:14 +1100 Subject: [PATCH 2/2] correct version to align with rules --- klaw-sync/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/klaw-sync/index.d.ts b/klaw-sync/index.d.ts index 09342094e0..d344879e1a 100644 --- a/klaw-sync/index.d.ts +++ b/klaw-sync/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for klaw-sync v1.1.2 +// Type definitions for klaw-sync 1.1 // Project: https://github.com/manidlou/node-klaw-sync // Definitions by: Brendan Forster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped