mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
26 lines
616 B
TypeScript
26 lines
616 B
TypeScript
import klawSync = require('klaw-sync')
|
|
import * as fs from 'fs'
|
|
|
|
const outputMessage = (result: klawSync.Item) => {
|
|
console.log(`file: ${result.path} has size '${result.stats.size}'`)
|
|
}
|
|
|
|
klawSync('/some/dir').forEach(outputMessage)
|
|
|
|
const defaultOptions: klawSync.Options = {}
|
|
|
|
klawSync('/some/dir', defaultOptions).forEach(outputMessage)
|
|
|
|
const options: klawSync.Options = {
|
|
nodir: true,
|
|
nofile: false,
|
|
filter(item: klawSync.Item) {
|
|
return item.path.indexOf('node_modules') < 0
|
|
},
|
|
depthLimit: 5,
|
|
fs,
|
|
traverseAll: true
|
|
}
|
|
|
|
klawSync('/some/dir', options).forEach(outputMessage)
|