Skip to content

find() raises error when unable to find any files matching, expected to return empty array. #653

@chtrinh

Description

@chtrinh

Node version (or tell us if you're using electron or some other framework):

node v7.4.0 and v5.9.0

ShellJS version (the most recent version/Github branch you see the bug on):

^0.7.6

Operating system:

MAC OS X 10.12.2 (16C67)

Description of the bug:

Raise and error ENOENT when shelljs can't find a directory or file matching the criteria.
Expected result to be an empty array instead.

Propose solution, wrap it in a try/catch block. Not sure able the implications here.
http://stackoverflow.com/a/33401005

Example ShellJS command to reproduce the error:

shell.find(`${overrideDirectory}**/*.json`);

ShellJS: internal error
Error: ENOENT: no such file or directory, stat 'overrides/dev/amp/**/*.json'
    at Object.fs.statSync (fs.js:907:18)
    at /Users/christ11/Workspace/v-configs/node_modules/shelljs/src/find.js:45:12
    at Array.forEach (native)
    at Object._find (/Users/christ11/Workspace/v-configs/node_modules/shelljs/src/find.js:42:9)
    at Object.find (/Users/christ11/Workspace/v-configs/node_modules/shelljs/src/common.js:365:25)
    at Object.exports.mergeOverrides (/Users/christ11/Workspace/v-configs/script/util.js:42:11)
    at portals.forEach.portal (/Users/christ11/Workspace/v-configs/script/build.js:27:14)
    at Array.forEach (native)
    at environments.forEach.env (/Users/christ11/Workspace/v-configs/script/build.js:20:13)
    at Array.forEach (native)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions