Skip to content
 
 

Latest commit

 

History

150 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@tdurieux/dinghy-diff

The Dinghy Diff library facilitates tree comparison between two Abstract Syntax Tree (AST) elements. It offers support for various operations such as add, remove, update, and move. This library builds upon the groundwork laid by @Toemmsche.

For detailed documentation, please visit https://durieux.me/dinghy-diff.

Installation

npm install @tdurieux/dinghy-diff

Usage

const fs = require("fs");
const dinghyDiff = require("@tdurieux/dinghy-diff");

// Calculate the difference between two source files
const oldPath = "path/to/original/document";
const newPath = "path/to/changed/document";


const tNodeSerDes = new dinghyDiff.ASTDataSerDes(dinghyDiff.defaultDiffOptions);
const oldTree = tNodeSerDes.parseFromString(fs.readFileSync(oldPath).toString());
const newTree = tNodeSerDes.parseFromString(fs.readFileSync(newPath).toString());
const editScript: dinghyDiff.EditScript<dinghyDiff.ASTData> = new dinghyDiff.SemanticDiff<dinghyDiff.ASTData>(dinghyDiff.defaultDiffOptions).diff(
  oldTree,
  newTree
);
console.log(editScript);

Command Line Interface

main.js diff <old> <new>

Calculate the difference between two source files. The supported languages are Dockerfile and Shell.

Positionals:
  old  Path to the original document                         [string] [required]
  new  Path to the changed document                          [string] [required]

Options:
      --help     Show help                                             [boolean]
      --version  Show version number                                   [boolean]
  -f, --format   Select the output format
           [string] [choices: "editScript", "deltaTree"] [default: "editScript"]

License

Dinghy-diff is licensed under the Apache License. See the LICENSE file for details.

About

A semantic diff for Dinghy

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages