Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should handle changes via symbolic links', () => {
let testDir = {
'orig_path': {
'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
'subdir-1': {
'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
}
},
'symlinks': {
'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
'subdir-1':
{'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
}
};
mockfs(testDir);
let differ = new TreeDiffer('testLabel', 'symlinks');
let diffResult = differ.diffTree();
expect(diffResult.addedPaths).toEqual([
'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
]);
// change two files
testDir['orig_path']['file-1.txt'] =
it('should handle changes via symbolic links', () => {
let testDir = {
'orig_path': {
'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
'subdir-1': {
'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
}
},
'symlinks': {
'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
'subdir-1':
{'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
}
};
mockfs(testDir);
let differ = new TreeDiffer('testLabel', 'symlinks');
let diffResult = differ.diffTree();
expect(diffResult.addedPaths).toEqual([
'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
]);
// change two files
testDir['orig_path']['file-1.txt'] =
mockfs.file({content: 'new content', mtime: new Date(1000)});
testDir['orig_path']['subdir-1']['file-1.1.txt'] =
it('should handle changes via symbolic links', () => {
let testDir = {
'orig_path': {
'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
'subdir-1': {
'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
}
},
'symlinks': {
'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
'subdir-1':
{'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
}
};
mockfs(testDir);
let differ = new TreeDiffer('testLabel', 'symlinks');
let diffResult = differ.diffTree();
expect(diffResult.addedPaths).toEqual([
'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
]);
// change two files
it('if the module was already linked, the link should be replaced', () => {
utils.init(modules).with({
'/moduleTmp': {
'package.json': {
'name': 'module3',
'version': '0.5.0'
}
},
'/var/module1': {
'package.json': {
dependencies: {
'module3': '0.3.0'
}
},
'node_modules': {
'module3': mockFs.symlink({
path: '/moduleTmp'
})
}
}
}).withCwd('/var/module1').apply();
expect(fs.readJsonSync('/var/module1/node_modules/module3/package.json')).to.have.property('version', '0.5.0');
return autoLink.linkModules('module3').then(() => {
expect(fs.readdirSync('/var/module1/node_modules')).to.have.all.members(['module3']);
expect(fs.readJsonSync('/var/module1/node_modules/module3/package.json')).to.have.property('version', '0.3.0');
});
});
},
'/moduleTmp2': {
'package.json': {
name: '@test/module2',
version: '0.2.0'
}
},
'/var/module1': {
'package.json': {
dependencies: {
'module3': '0.3.0',
'@test/module2': '*'
}
},
'node_modules': {
'module3': mockFs.symlink({
path: '/moduleTmp'
}),
'@test': {
'module2': mockFs.symlink({
path: '/moduleTmp2'
}),
}
}
}
}).withCwd('/var/module1').apply();
})
before(function () {
mock({
'.git': {},
'folder1': {
'folder1-1': {}
},
'zfolder2': {},
'some.png': new Buffer([8, 6, 7, 5, 3, 0, 9]),
'a-symlink': mock.symlink({
path: 'folder1'
})
});
});
beforeEach(function() {
mockFs({
'/fake_dir': {
'example_file.md': 'example content.',
'another_example_file.md': 'example content.',
'another_dir': {
'a.js': '...',
'b.js': '...',
'c.php': '...',
'k.php': '...',
'd.html': '...',
'g.md': mockFs.symlink({
path: '/fake_dir/example_file.md'
}),
'README.md': '...',
'document.txt': '...',
'.dir': {},
'foo.rb': '...'
},
}
});
});
beforeEach(function() {
mockFs({
'/fake_dir': {
'example_file.md': 'example content.',
'another_example_file.md': 'example content.',
'another_dir': {
'a.js': '...',
'b.md': mockFs.symlink({
path: '/fake_dir/another_example_file.md'
})
},
}
}, { createCwd: false });
});
version: '0.2.0'
}
},
'/var/module1': {
'package.json': {
dependencies: {
'module3': '0.3.0',
'@test/module2': '*'
}
},
'node_modules': {
'module3': mockFs.symlink({
path: '/moduleTmp'
}),
'@test': {
'module2': mockFs.symlink({
path: '/moduleTmp2'
}),
}
}
}
}).withCwd('/var/module1').apply();
})