Thanks to visit codestin.com
Credit goes to github.com

Skip to content

skipSubdirs still compares the directories themselves #77

@hudsonm62

Description

@hudsonm62

As the title says, skipSubdirs still compares directories themselves. Not sure what the intended functionality is, but I expected it to be ignored all together in the compare.

This extends gliviu/dir-compare-cli#1

File structure

.\compare
│   d_file2.txt
│   m_file1.txt
│   m_file3.txt
│
├───directory1
│       d_file2.txt
│       m_file1.txt
│       m_file3.txt
│
└───directory2
        d_file2.txt
        m_file1.txt
        m_file3.txt

Reproduction Script

const diff = require("dir-compare")

const options = {
  skipSubdirs: true,
}

const input = {
  path1: "./compare/directory1",
  path2: "./compare/",
}

diff
  .compare(input.path1, input.path2, options)
  .then((results) => {
    results.diffSet.forEach((d) => {
      const differenceString = `${d.relativePath}${d.name1} (${d.type1}): ${d.state} - ${d.name2} (${d.type2})`
      console.log(differenceString)
    })
  })
  .catch((error) => {
    throw new Error(error)
  })

Outputs

> node .\test.js

\undefined (missing): right - directory1 (directory)
\undefined (missing): right - directory2 (directory)
\d_file2.txt (file): equal - d_file2.txt (file)     
\m_file1.txt (file): equal - m_file1.txt (file)     
\m_file3.txt (file): equal - m_file3.txt (file)

With skipSubdirs: false

> node .\test.js
\undefined (missing): right - directory1 (directory)
\directory1undefined (missing): right - d_file2.txt (file)
\directory1undefined (missing): right - m_file1.txt (file)
\directory1undefined (missing): right - m_file3.txt (file)
\undefined (missing): right - directory2 (directory)
\directory2undefined (missing): right - d_file2.txt (file)
\directory2undefined (missing): right - m_file1.txt (file)
\directory2undefined (missing): right - m_file3.txt (file)
\d_file2.txt (file): equal - d_file2.txt (file)
\m_file1.txt (file): equal - m_file1.txt (file)
\m_file3.txt (file): equal - m_file3.txt (file)

edit- typo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions