Comparing version 1.0.1 to 1.0.2
@@ -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); | ||
}; |
{ | ||
"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'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7750
179
1