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

tree-sync

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-sync - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

9

index.js

@@ -14,2 +14,3 @@ 'use strict';

this._output = output;
this._hasSynced = false;
this._lastInput = FSTree.fromEntries([]);

@@ -31,4 +32,9 @@

var isFirstSync = !this._hasSynced;
var operations = output.calculatePatch(input).filter(function(operation) {
return operation[0] !== 'change';
if (operation[0] === 'change') {
return isFirstSync;
} else {
return true;
}
});

@@ -69,3 +75,4 @@

this._hasSynced = true;
debug('applied patches: %d', operations.length);
};

2

package.json
{
"name": "tree-sync",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -96,2 +96,44 @@ var expect = require('chai').expect;

describe('output populated -> input with a changed file', function() {
var changeFilePath = __dirname + '/fixtures/one/foo.txt';
var originalValue, initialTree;
beforeEach(function() {
originalValue = fs.readFileSync(changeFilePath, { encoding: 'utf8' });
// populate tmp simulating a pre-existing output
treeSync.sync();
// grab state of `tmp` after initial sync
initialTree = walkSync.entries(tmp);
// change a file in the input tree
fs.writeFileSync(changeFilePath, 'OMG');
// build a new `TreeSync` that does not have `lastInput` populated
treeSync = new TreeSync(__dirname + '/fixtures/', tmp);
treeSync.sync();
});
afterEach(function() {
originalValue = fs.writeFileSync(changeFilePath, originalValue, { encoding: 'utf8' });
});
it('should update changed files on initial build', function() {
var afterTree = walkSync.entries(tmp);
// tree should be updated with OMG in one/foo.txt
expect(initialTree).to.not.deep.equal(afterTree);
var contents = fs.readFileSync(tmp + '/one/foo.txt', { encoding: 'utf8'} );
expect(contents).to.equal('OMG');
// sync again to ensure stablity after synced
treeSync.sync();
expect(afterTree).to.deep.equal(walkSync.entries(tmp));
});
});
describe('input(same) -> input(same - file)', function() {

@@ -98,0 +140,0 @@ var removedFilePath = __dirname + '/fixtures/one/foo.txt';

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