+8
-1
@@ -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); | ||
| }; |
+1
-1
| { | ||
| "name": "tree-sync", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+42
-0
@@ -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'; |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
7750
25%179
25.17%1
Infinity%