Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crawl-path

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crawl-path - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

1

__test__/crawlPath.test.ts

@@ -15,2 +15,3 @@ import {crawlPath} from '../src/crawlPath'

console.log(file)
return null
}

@@ -17,0 +18,0 @@ })

2

package.json
{
"name": "crawl-path",
"version": "0.0.1",
"version": "0.0.2",
"main": "src/crawlPath",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1,2 +0,2 @@

#usage
# usage

@@ -10,4 +10,6 @@ ```bash

let files = new Map<string, string|string[]>()
import {crawlPath} from 'crawl-path'
let files = new Map
await crawlPath(path.join(__dirname, 'foo'), {

@@ -14,0 +16,0 @@ onDir: async (_files, _path, depth) => {

import * as fs from 'fs-extra-promise'
interface crawOption {
onDir: (files:string|string[], _path: string, depth: number) => void;
onFile: (file:string) => void;
onDir: (files: string | string[], _path: string, depth: number) => Promise<void>;
onFile: (file: string) => Promise<void>;
}
export async function crawlPath (_path, options:crawOption, depth = 0) {
if(await isDir(_path)) {
depth += 1
const files = await fs.readdirAsync(_path)
options.onDir(files, _path, depth)
export async function crawlPath(_path, options: crawOption, depth = 0) {
if (await isDir(_path)) {
depth += 1
const files = await fs.readdirAsync(_path)
await options.onDir(files, _path, depth)
if(files) {
for (let fileName of files) {
const file = `${_path}/${fileName}`
if (files) {
for (let fileName of files) {
const file = `${_path}/${fileName}`
if(await isDir(file)){
await crawlPath(file, options, depth)
} else if(isFile(file)) {
options.onFile(file)
}
if (await isDir(file)) {
await crawlPath(file, options, depth)
} else if (await isFile(file)) {
await options.onFile(file)
}
}
} else if(await isFile(_path)) {
options.onFile && options.onFile(_path)
}
} else if (await isFile(_path)) {
await options.onFile(_path)
}
}

@@ -29,0 +29,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc