vastec / ember-unused-components

Search for unused components in your Ember project
51 stars 12 forks source link

Sometimes doesn't throw an error when `--path` is wrong #27

Open tniezurawski opened 5 years ago

tniezurawski commented 5 years ago

Consider these:

➜  ember-unused-components git:(master) ./index.js --path="test-apps/ember_3_10_mu/" --stats
Can't find Ember config. Are you sure you are running this in root directory?

☝️ That's ok. The path was wrong. The error was thrown. πŸ‘‡ That's not ok. A small change in path with / at the beginning but not at the end and it crashes:

➜  ember-unused-components git:(master) ./index.js --path="/test-apps/ember_3_10_mu" --stats
[1/3] πŸ—ΊοΈ  Mapping the project...
fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir './/test-apps/ember_3_10_musrc/ui/components'
    at Object.readdirSync (fs.js:790:3)
    at Object.mapComponents (/Users/tomek/Projects/my/ember-unused-components/lib/analyser.js:231:20)
    at main (/Users/tomek/Projects/my/ember-unused-components/index.js:36:12)
    at Object.<anonymous> (/Users/tomek/Projects/my/ember-unused-components/index.js:46:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)