Skip to content

Commit da32628

Browse files
committed
fix: test failure in macos
1 parent cc97726 commit da32628

6 files changed

Lines changed: 211 additions & 173 deletions

File tree

dist/phoenix-fs.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const WebSocket = require('ws');
22
const fs = require("fs/promises");
33
const path = require("path");
4+
const os = require('os');
45
const { exec } = require('child_process');
56

7+
const IS_MACOS = os.platform() === 'darwin';
8+
69
function getWindowsDrives(callback) {
710
exec('wmic logicaldisk get name', (error, stdout) => {
811
if (error) {
@@ -153,7 +156,7 @@ function _reportError(ws, metadata, err, defaultMessage = "Operation failed! ")
153156
metadata.error = {
154157
message: err.message || defaultMessage,
155158
code: err.code || "EIO",
156-
stack: err.stack
159+
nodeStack: err.stack
157160
};
158161
_sendResponse(ws, metadata);
159162
}
@@ -169,7 +172,10 @@ function _readDir(ws, metadata) {
169172
if(withFileTypes){
170173
let statPromises = [];
171174
for(let name of contents) {
172-
statPromises.push(_getStat(path.join(fullPath, name)));
175+
const contentPath = path.join(fullPath, name);
176+
if(!IS_MACOS || (IS_MACOS && contentPath !== '/.VolumeIcon.icns')) { // in mac, this file in the root fs is not accessible.
177+
statPromises.push(_getStat(contentPath));
178+
}
173179
}
174180
Promise.all(statPromises)
175181
.then(contentStats =>{

0 commit comments

Comments
 (0)