diff --git a/klaw-sync/index.d.ts b/klaw-sync/index.d.ts new file mode 100644 index 0000000000..d344879e1a --- /dev/null +++ b/klaw-sync/index.d.ts @@ -0,0 +1,37 @@ +// 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 + +/// + +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" + ] + } +}