Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.activate = context => {
const folderFullPath = path.join(workspaceRoot, folderPath);

// Read folder, built quick pick with files/folder (and shortcuts)
fs.readdir(folderFullPath, async (readErr, files) => {
fs.readdir(folderFullPath, { withFileTypes: true }, async (readErr, files) => {
if (readErr) {
if (folderPath === nodeModulesPath) {
return showError('No node_modules folder in this workspace.');
Expand All @@ -55,7 +55,7 @@ exports.activate = context => {
} else {
// Otherwise, show option to move back to root
options.push('');
options.push(workspaceNodeModules);
options.push(`${workspaceNodeModules}${path.sep}`);

// If current folder is not outside of the workspace, also add option to move a step back
if (!isParentFolder) {
Expand Down
8 changes: 6 additions & 2 deletions sort-files.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const path = require('path');

const sortFiles = (origFiles, origPriorities) => {
const priorities = [ ...origPriorities ].reverse().map(p => p.toLowerCase());
const files = origFiles.map(file => ({ original: file, lower: file.toLowerCase() }));
const files = origFiles.map(file => ({ original: file, lower: file.name.toLowerCase() }));
const rank = file => priorities.indexOf(file) + 1;

return files
.sort((a, b) => rank(b.lower) - rank(a.lower))
.map(file => file.original);
.map(({ original }) => original.isDirectory()
? `${original.name}${path.sep}`
: original.name);
};

module.exports = { sortFiles };