Skip to content

Commit 58e833d

Browse files
authored
fix: handle permissions error on directory creation (#5480)
* fix: handle permissions error on directory creation * refactor: common error message
1 parent d312f14 commit 58e833d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/common/file-system.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,16 @@ export class FileSystem implements IFileSystem {
200200
}
201201

202202
public createDirectory(path: string): void {
203-
mkdirp.sync(path);
203+
try {
204+
mkdirp.sync(path);
205+
} catch (error) {
206+
const $errors = this.$injector.resolve("errors");
207+
let errorMessage = `Unable to create directory ${path}. \nError is: ${error}.`;
208+
if (error.code === "EACCES") {
209+
errorMessage += "\n\nYou may need to call the command with 'sudo'.";
210+
}
211+
$errors.fail(errorMessage);
212+
}
204213
}
205214

206215
public readDirectory(path: string): string[] {

0 commit comments

Comments
 (0)