Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handling permissions errors on file I/O #64

@khawkins

Description

@khawkins

It would be nice if shelljs gracefully handled file I/O errors due to permissions issues, as opposed to the current full error dump you get now:

    var shelljs = require('./shelljs');
    shelljs.mkdir('-p', '/var/log/myNewDir');

    $ node shelljsConsumer.js
    shell.js: internal error
    Error: EACCES, permission denied '/var/log/myNewDir'
        at Object.fs.mkdirSync (fs.js:642:18)
        at mkdirSyncRecursive (shell.js:1649:8)
        at shell.js:541:7
        at Array.forEach (native)
        at Object._mkdir (shell.js:526:8)
        at Object.mkdir (shell.js:1491:23)
        at Object.<anonymous> (shelljsConsumer.js:2:10)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)

It seems like, for a lot of use cases (like this one), a more user-friendly error handling path could be initiated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bash compatCompatibility issues with bash or POSIX behaviorfixBug/defect, or a fix for such a problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions