mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
detect symbolic link packages
* detect symbolic link packages
This commit is contained in:
parent
10dfeb8c56
commit
5b2c05a745
4
spec/fixtures/packages/folder/package-symlinked/package.json
vendored
Normal file
4
spec/fixtures/packages/folder/package-symlinked/package.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "package-symlinked",
|
||||
"version": "0.1.0"
|
||||
}
|
@ -1890,4 +1890,26 @@ describe('PackageManager', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('::getAvailablePackageNames', () => {
|
||||
it('detects a symlinked package', () => {
|
||||
const packageSymLinkedSource = path.join(
|
||||
__dirname,
|
||||
'fixtures',
|
||||
'packages',
|
||||
'folder',
|
||||
'package-symlinked'
|
||||
);
|
||||
const destination = path.join(
|
||||
atom.packages.getPackageDirPaths()[0],
|
||||
'package-symlinked'
|
||||
);
|
||||
if (!fs.isDirectorySync(destination)) {
|
||||
fs.symlinkSync(packageSymLinkedSource, destination, 'junction');
|
||||
}
|
||||
const availablePackages = atom.packages.getAvailablePackageNames();
|
||||
expect(availablePackages.includes('package-symlinked')).toBe(true);
|
||||
fs.removeSync(destination);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -419,9 +419,16 @@ module.exports = class PackageManager {
|
||||
|
||||
for (const packageDirPath of this.packageDirPaths) {
|
||||
if (fs.isDirectorySync(packageDirPath)) {
|
||||
// checks for directories.
|
||||
// dirent is faster, but for checking symbolic link we need stat.
|
||||
const packageNames = fs
|
||||
.readdirSync(packageDirPath, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.filter(
|
||||
dirent =>
|
||||
dirent.isDirectory() ||
|
||||
(dirent.isSymbolicLink() &&
|
||||
fs.isDirectorySync(path.join(packageDirPath, dirent.name)))
|
||||
)
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
for (const packageName of packageNames) {
|
||||
|
Loading…
Reference in New Issue
Block a user